Skip to content

Commit ea2dbae

Browse files
Added unit tests
1 parent d930616 commit ea2dbae

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

test/fixtures/nodebalancers_123456_configs.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,35 @@
2424
"protocol": "http",
2525
"ssl_fingerprint": "",
2626
"proxy_protocol": "none"
27+
},
28+
{
29+
"check": "connection",
30+
"check_attempts": 2,
31+
"stickiness": "table",
32+
"check_interval": 5,
33+
"check_body": "",
34+
"id": 65431,
35+
"check_passive": true,
36+
"algorithm": "roundrobin",
37+
"check_timeout": 3,
38+
"check_path": "/",
39+
"ssl_cert": null,
40+
"ssl_commonname": "",
41+
"port": 80,
42+
"nodebalancer_id": 123456,
43+
"cipher_suite": "recommended",
44+
"ssl_key": null,
45+
"nodes_status": {
46+
"up": 0,
47+
"down": 0
48+
},
49+
"protocol": "udp",
50+
"ssl_fingerprint": "",
51+
"proxy_protocol": "none",
52+
"udp_check_port": 12345
2753
}
2854
],
29-
"results": 1,
55+
"results": 2,
3056
"page": 1,
3157
"pages": 1
3258
}

test/fixtures/nodebalancers_123456_configs_65432_nodes.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@
99
"mode": "accept",
1010
"config_id": 54321,
1111
"nodebalancer_id": 123456
12+
},
13+
{
14+
"id": 12345,
15+
"address": "192.168.210.120",
16+
"label": "node12345",
17+
"status": "UP",
18+
"weight": 50,
19+
"mode": "none",
20+
"config_id": 123456,
21+
"nodebalancer_id": 123456
1222
}
1323
],
1424
"pages": 1,
1525
"page": 1,
16-
"results": 1
26+
"results": 2
1727
}

test/unit/objects/nodebalancers_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def test_get_config(self):
4242
self.assertEqual(config.ssl_fingerprint, "")
4343
self.assertEqual(config.proxy_protocol, "none")
4444

45+
config_udp = NodeBalancerConfig(self.client, 65431, 123456)
46+
self.assertEqual(config_udp.protocol, "udp")
47+
self.assertEqual(config_udp.udp_check_port, 12345)
48+
4549

4650
class NodeBalancerNodeTest(ClientBaseCase):
4751
"""
@@ -66,6 +70,9 @@ def test_get_node(self):
6670
self.assertEqual(node.config_id, 65432)
6771
self.assertEqual(node.nodebalancer_id, 123456)
6872

73+
node_udp = NodeBalancerNode(self.client, 12345, (65432, 123456))
74+
self.assertEqual(node_udp.mode, "none")
75+
6976
def test_create_node(self):
7077
"""
7178
Tests that a node can be created

0 commit comments

Comments
 (0)