mirror of https://github.com/docker/docker-py.git
Unit and integration tests for pause/unpause.
This commit is contained in:
parent
75e53f1add
commit
288e53b28b
|
@ -237,6 +237,18 @@ def post_fake_kill_container():
|
|||
return status_code, response
|
||||
|
||||
|
||||
def post_fake_pause_container():
|
||||
status_code = 200
|
||||
response = {'Id': FAKE_CONTAINER_ID}
|
||||
return status_code, response
|
||||
|
||||
|
||||
def post_fake_unpause_container():
|
||||
status_code = 200
|
||||
response = {'Id': FAKE_CONTAINER_ID}
|
||||
return status_code, response
|
||||
|
||||
|
||||
def post_fake_restart_container():
|
||||
status_code = 200
|
||||
response = {'Id': FAKE_CONTAINER_ID}
|
||||
|
@ -334,6 +346,10 @@ fake_responses = {
|
|||
post_fake_stop_container,
|
||||
'{1}/{0}/containers/3cc2351ab11b/kill'.format(CURRENT_VERSION, prefix):
|
||||
post_fake_kill_container,
|
||||
'{1}/{0}/containers/3cc2351ab11b/pause'.format(CURRENT_VERSION, prefix):
|
||||
post_fake_pause_container,
|
||||
'{1}/{0}/containers/3cc2351ab11b/unpause'.format(CURRENT_VERSION, prefix):
|
||||
post_fake_unpause_container,
|
||||
'{1}/{0}/containers/3cc2351ab11b/json'.format(CURRENT_VERSION, prefix):
|
||||
get_fake_port,
|
||||
'{1}/{0}/containers/3cc2351ab11b/restart'.format(CURRENT_VERSION, prefix):
|
||||
|
|
|
@ -627,6 +627,37 @@ class TestRestartingContainer(BaseTestCase):
|
|||
res = [x for x in containers if 'Id' in x and x['Id'].startswith(id)]
|
||||
self.assertEqual(len(res), 0)
|
||||
|
||||
|
||||
class TestPauseUnpauseContainer(BaseTestCase):
|
||||
def runTest(self):
|
||||
container = self.client.create_container('busybox', ['sleep', '9999'])
|
||||
id = container['Id']
|
||||
self.client.start(id)
|
||||
self.tmp_containers.append(id)
|
||||
|
||||
self.client.pause(id)
|
||||
container_info = self.client.inspect_container(id)
|
||||
self.assertIn('State', container_info)
|
||||
state = container_info['State']
|
||||
self.assertIn('ExitCode', state)
|
||||
self.assertEqual(state['ExitCode'], 0)
|
||||
self.assertIn('Running', state)
|
||||
self.assertEqual(state['Running'], True)
|
||||
self.assertIn('Paused', state)
|
||||
self.assertEqual(state['Paused'], True)
|
||||
|
||||
self.client.unpause(id)
|
||||
container_info = self.client.inspect_container(id)
|
||||
self.assertIn('State', container_info)
|
||||
state = container_info['State']
|
||||
self.assertIn('ExitCode', state)
|
||||
self.assertEqual(state['ExitCode'], 0)
|
||||
self.assertIn('Running', state)
|
||||
self.assertEqual(state['Running'], True)
|
||||
self.assertIn('Paused', state)
|
||||
self.assertEqual(state['Paused'], False)
|
||||
|
||||
|
||||
#################
|
||||
# LINKS TESTS #
|
||||
#################
|
||||
|
|
|
@ -1064,6 +1064,26 @@ class DockerClientTest(Cleanup, unittest.TestCase):
|
|||
timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS + timeout)
|
||||
)
|
||||
|
||||
def test_pause_container(self):
|
||||
try:
|
||||
self.client.pause(fake_api.FAKE_CONTAINER_ID)
|
||||
except Exception as e:
|
||||
self.fail('Command should not raise exception: {0}'.format(e))
|
||||
fake_request.assert_called_with(
|
||||
url_prefix + 'containers/3cc2351ab11b/pause',
|
||||
timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS)
|
||||
)
|
||||
|
||||
def test_unpause_container(self):
|
||||
try:
|
||||
self.client.unpause(fake_api.FAKE_CONTAINER_ID)
|
||||
except Exception as e:
|
||||
self.fail('Command should not raise exception: {0}'.format(e))
|
||||
fake_request.assert_called_with(
|
||||
url_prefix + 'containers/3cc2351ab11b/unpause',
|
||||
timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS)
|
||||
)
|
||||
|
||||
def test_kill_container(self):
|
||||
try:
|
||||
self.client.kill(fake_api.FAKE_CONTAINER_ID)
|
||||
|
|
Loading…
Reference in New Issue