@@ -30,3 +30,46 @@ def test_node_update(self):
30
30
self .assertEqual (
31
31
args [1 ]['headers' ]['Content-Type' ], 'application/json'
32
32
)
33
+
34
+ @requires_api_version ('1.24' )
35
+ def test_join_swarm (self ):
36
+ remote_addr = ['1.2.3.4:2377' ]
37
+ listen_addr = '2.3.4.5:2377'
38
+ join_token = 'A_BEAUTIFUL_JOIN_TOKEN'
39
+
40
+ data = {
41
+ 'RemoteAddrs' : remote_addr ,
42
+ 'ListenAddr' : listen_addr ,
43
+ 'JoinToken' : join_token
44
+ }
45
+
46
+ self .client .join_swarm (
47
+ remote_addrs = remote_addr ,
48
+ listen_addr = listen_addr ,
49
+ join_token = join_token
50
+ )
51
+
52
+ args = fake_request .call_args
53
+
54
+ assert (args [0 ][1 ] == url_prefix + 'swarm/join' )
55
+ assert (json .loads (args [1 ]['data' ]) == data )
56
+ assert (args [1 ]['headers' ]['Content-Type' ] == 'application/json' )
57
+
58
+ @requires_api_version ('1.24' )
59
+ def test_join_swarm_no_listen_address_takes_default (self ):
60
+ remote_addr = ['1.2.3.4:2377' ]
61
+ join_token = 'A_BEAUTIFUL_JOIN_TOKEN'
62
+
63
+ data = {
64
+ 'RemoteAddrs' : remote_addr ,
65
+ 'ListenAddr' : '0.0.0.0:2377' ,
66
+ 'JoinToken' : join_token
67
+ }
68
+
69
+ self .client .join_swarm (remote_addrs = remote_addr , join_token = join_token )
70
+
71
+ args = fake_request .call_args
72
+
73
+ assert (args [0 ][1 ] == url_prefix + 'swarm/join' )
74
+ assert (json .loads (args [1 ]['data' ]) == data )
75
+ assert (args [1 ]['headers' ]['Content-Type' ] == 'application/json' )
0 commit comments