Skip to content

Commit fc27a62

Browse files
fix: Make NodeBalancer.tags mutable (linode#371)
* Make NodeBalancer.tags mutable * Use printf * make format
1 parent 10ad316 commit fc27a62

File tree

4 files changed

+51
-14
lines changed

4 files changed

+51
-14
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ build: clean create-version
2828

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

3333
.PHONY: release
3434
release: build

linode_api4/objects/nodebalancer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class NodeBalancer(Base):
217217
"region": Property(slug_relationship=Region),
218218
"configs": Property(derived_class=NodeBalancerConfig),
219219
"transfer": Property(),
220-
"tags": Property(),
220+
"tags": Property(mutable=True),
221221
}
222222

223223
# create derived objects
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"created": "2018-01-01T00:01:01",
3+
"ipv6": "c001:d00d:b01::1:abcd:1234",
4+
"region": "us-east-1a",
5+
"ipv4": "12.34.56.789",
6+
"hostname": "nb-12-34-56-789.newark.nodebalancer.linode.com",
7+
"id": 123456,
8+
"updated": "2018-01-01T00:01:01",
9+
"label": "balancer123456",
10+
"client_conn_throttle": 0,
11+
"tags": [
12+
"something"
13+
]
14+
}

test/unit/objects/nodebalancers_test.py

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,41 @@ def test_delete_node(self):
132132
m.call_url, "/nodebalancers/123456/configs/65432/nodes/54321"
133133
)
134134

135+
136+
class NodeBalancerTest(ClientBaseCase):
137+
def test_update(self):
138+
"""
139+
Test that you can update a NodeBalancer.
140+
"""
141+
nb = NodeBalancer(self.client, 123456)
142+
nb.label = "updated-label"
143+
nb.client_conn_throttle = 7
144+
nb.tags = ["foo", "bar"]
145+
146+
with self.mock_put("nodebalancers/123456") as m:
147+
nb.save()
148+
self.assertEqual(m.call_url, "/nodebalancers/123456")
149+
self.assertEqual(
150+
m.call_data,
151+
{
152+
"label": "updated-label",
153+
"client_conn_throttle": 7,
154+
"tags": ["foo", "bar"],
155+
},
156+
)
157+
158+
def test_firewalls(self):
159+
"""
160+
Test that you can get the firewalls for the requested NodeBalancer.
161+
"""
162+
nb = NodeBalancer(self.client, 12345)
163+
firewalls_url = "/nodebalancers/12345/firewalls"
164+
165+
with self.mock_get(firewalls_url) as m:
166+
result = nb.firewalls()
167+
self.assertEqual(m.call_url, firewalls_url)
168+
self.assertEqual(len(result), 1)
169+
135170
def test_config_rebuild(self):
136171
"""
137172
Test that you can rebuild the cofig of a node balancer.
@@ -193,15 +228,3 @@ def test_statistics(self):
193228
"linode.com - balancer12345 (12345) - day (5 min avg)",
194229
)
195230
self.assertEqual(m.call_url, statistics_url)
196-
197-
def test_firewalls(self):
198-
"""
199-
Test that you can get the firewalls for the requested NodeBalancer.
200-
"""
201-
nb = NodeBalancer(self.client, 12345)
202-
firewalls_url = "/nodebalancers/12345/firewalls"
203-
204-
with self.mock_get(firewalls_url) as m:
205-
result = nb.firewalls()
206-
self.assertEqual(m.call_url, firewalls_url)
207-
self.assertEqual(len(result), 1)

0 commit comments

Comments
 (0)