@@ -113,6 +113,29 @@ def test_create_node(self):
113113 },
114114 )
115115
116+ def test_create_ipv6_node (self ):
117+ """
118+ Tests that a node can be created with a public IPv6 backend address.
119+ """
120+ with self .mock_post (
121+ "nodebalancers/123456/configs/65432/nodes/54321"
122+ ) as m :
123+ config = NodeBalancerConfig (self .client , 65432 , 123456 )
124+ node = config .node_create (
125+ "node54321" ,
126+ "[2001:db8:abcd:0012::1]:80" ,
127+ weight = 50 ,
128+ mode = "accept" ,
129+ )
130+
131+ self .assertIsNotNone (node )
132+ self .assertEqual (
133+ m .call_url , "/nodebalancers/123456/configs/65432/nodes"
134+ )
135+ self .assertEqual (
136+ m .call_data ["address" ], "[2001:db8:abcd:0012::1]:80"
137+ )
138+
116139 def test_update_node (self ):
117140 """
118141 Tests that a node can be updated
@@ -154,6 +177,18 @@ def test_delete_node(self):
154177
155178
156179class NodeBalancerTest (ClientBaseCase ):
180+ def test_get (self ):
181+ """
182+ Tests that a NodeBalancer is loaded correctly by ID.
183+ """
184+ nb = NodeBalancer (self .client , 123456 )
185+ self .assertEqual (nb ._populated , False )
186+
187+ self .assertEqual (nb .label , "balancer123456" )
188+ self .assertEqual (nb ._populated , True )
189+ self .assertEqual (nb .type , "premium" )
190+ self .assertEqual (nb .backend_connectivity , "ipv6" )
191+
157192 def test_update (self ):
158193 """
159194 Test that you can update a NodeBalancer.
@@ -193,6 +228,24 @@ def test_locks_not_in_put(self):
193228 self .assertNotIn ("locks" , m .call_data )
194229 self .assertEqual (m .call_data ["label" ], "new-label" )
195230
231+ def test_type_and_backend_connectivity_not_in_put (self ):
232+ """
233+ Test that type and backend_connectivity are not included in PUT
234+ requests. These fields cannot be changed after creation.
235+ """
236+ nb = NodeBalancer (self .client , 123456 )
237+ self .assertEqual (nb .type , "premium" )
238+ self .assertEqual (nb .backend_connectivity , "ipv6" )
239+
240+ nb .label = "new-label"
241+
242+ with self .mock_put ("nodebalancers/123456" ) as m :
243+ nb .save ()
244+ self .assertEqual (m .call_url , "/nodebalancers/123456" )
245+ self .assertNotIn ("type" , m .call_data )
246+ self .assertNotIn ("backend_connectivity" , m .call_data )
247+ self .assertEqual (m .call_data ["label" ], "new-label" )
248+
196249 def test_firewalls (self ):
197250 """
198251 Test that you can get the firewalls for the requested NodeBalancer.
@@ -251,6 +304,30 @@ def test_config_rebuild(self):
251304 },
252305 )
253306
307+ def test_config_rebuild_ipv6 (self ):
308+ """
309+ Test that a config can be rebuilt with public IPv6 backend addresses.
310+ """
311+ config_rebuild_url = "/nodebalancers/12345/configs/4567/rebuild"
312+ with self .mock_post (config_rebuild_url ) as m :
313+ nb = NodeBalancer (self .client , 12345 )
314+ nodes = [
315+ {
316+ "address" : "[2001:db8:abcd:0012::1]:80" ,
317+ "label" : "node1" ,
318+ "weight" : 50 ,
319+ "mode" : "accept" ,
320+ }
321+ ]
322+
323+ result = nb .config_rebuild (4567 , nodes , port = 80 , protocol = "http" )
324+ self .assertIsNotNone (result )
325+ self .assertEqual (m .call_url , config_rebuild_url )
326+ self .assertEqual (
327+ m .call_data ["nodes" ][0 ]["address" ],
328+ "[2001:db8:abcd:0012::1]:80" ,
329+ )
330+
254331 def test_statistics (self ):
255332 """
256333 Test that you can get the statistics about the requested NodeBalancer.
0 commit comments