From 110c6769c93cd9c8bf20cc88c520a9f97afc040e Mon Sep 17 00:00:00 2001 From: Hannes Ljungberg Date: Sun, 31 Mar 2019 23:10:23 +0200 Subject: [PATCH] Add test for join on already joined swarm Signed-off-by: Hannes Ljungberg --- tests/integration/models_swarm_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/integration/models_swarm_test.py b/tests/integration/models_swarm_test.py index f39f0d34..6c1836dc 100644 --- a/tests/integration/models_swarm_test.py +++ b/tests/integration/models_swarm_test.py @@ -31,3 +31,15 @@ class SwarmTest(unittest.TestCase): cm.value.response.status_code == 406 or cm.value.response.status_code == 503 ) + + def test_join_on_already_joined_swarm(self): + client = docker.from_env(version=TEST_API_VERSION) + client.swarm.init() + join_token = client.swarm.attrs['JoinTokens']['Manager'] + with pytest.raises(docker.errors.APIError) as cm: + client.swarm.join( + remote_addrs=['127.0.0.1'], + join_token=join_token, + ) + assert cm.value.response.status_code == 503 + assert 'This node is already part of a swarm.' in cm.value.explanation