Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ build: clean create-version

.PHONY: create-version
create-version:
@echo "${VERSION_MODULE_DOCSTRING}__version__ = \"${LINODE_SDK_VERSION}\"" > $(VERSION_FILE)
@printf "${VERSION_MODULE_DOCSTRING}__version__ = \"${LINODE_SDK_VERSION}\"\n" > $(VERSION_FILE)

.PHONY: release
release: build
Expand Down
2 changes: 1 addition & 1 deletion linode_api4/objects/nodebalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class NodeBalancer(Base):
"region": Property(slug_relationship=Region),
"configs": Property(derived_class=NodeBalancerConfig),
"transfer": Property(),
"tags": Property(),
"tags": Property(mutable=True),
}

# create derived objects
Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/nodebalancers_123456.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"created": "2018-01-01T00:01:01",
"ipv6": "c001:d00d:b01::1:abcd:1234",
"region": "us-east-1a",
"ipv4": "12.34.56.789",
"hostname": "nb-12-34-56-789.newark.nodebalancer.linode.com",
"id": 123456,
"updated": "2018-01-01T00:01:01",
"label": "balancer123456",
"client_conn_throttle": 0,
"tags": [
"something"
]
}
47 changes: 35 additions & 12 deletions test/unit/objects/nodebalancers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,41 @@ def test_delete_node(self):
m.call_url, "/nodebalancers/123456/configs/65432/nodes/54321"
)


class NodeBalancerTest(ClientBaseCase):
def test_update(self):
"""
Test that you can update a NodeBalancer.
"""
nb = NodeBalancer(self.client, 123456)
nb.label = "updated-label"
nb.client_conn_throttle = 7
nb.tags = ["foo", "bar"]

with self.mock_put("nodebalancers/123456") as m:
nb.save()
self.assertEqual(m.call_url, "/nodebalancers/123456")
self.assertEqual(
m.call_data,
{
"label": "updated-label",
"client_conn_throttle": 7,
"tags": ["foo", "bar"],
},
)

def test_firewalls(self):
"""
Test that you can get the firewalls for the requested NodeBalancer.
"""
nb = NodeBalancer(self.client, 12345)
firewalls_url = "/nodebalancers/12345/firewalls"

with self.mock_get(firewalls_url) as m:
result = nb.firewalls()
self.assertEqual(m.call_url, firewalls_url)
self.assertEqual(len(result), 1)

def test_config_rebuild(self):
"""
Test that you can rebuild the cofig of a node balancer.
Expand Down Expand Up @@ -193,15 +228,3 @@ def test_statistics(self):
"linode.com - balancer12345 (12345) - day (5 min avg)",
)
self.assertEqual(m.call_url, statistics_url)

def test_firewalls(self):
"""
Test that you can get the firewalls for the requested NodeBalancer.
"""
nb = NodeBalancer(self.client, 12345)
firewalls_url = "/nodebalancers/12345/firewalls"

with self.mock_get(firewalls_url) as m:
result = nb.firewalls()
self.assertEqual(m.call_url, firewalls_url)
self.assertEqual(len(result), 1)