def test_ports(self): g = Gantry() assert_equal([[12345, 8000], [12346, 8000], [12347, 8001]], g.ports('foo', tags=['123'])) assert_equal([], g.ports('bar', tags=['abc'])) assert_equal([], g.ports('bar', tags=['cde']))
def test_containers_exclude_tags(self): g = Gantry() res = g.containers("foo", exclude_tags=["122"]) assert_containers(["1da4", "5e68", "6000"], res) res = g.containers("foo", exclude_tags=["122", "123"]) assert_containers([], res)
def test_containers_exclude_tags(self): g = Gantry() res = g.containers('foo', exclude_tags=['122']) assert_containers(['1da4', '5e68', '6000'], res) res = g.containers('foo', exclude_tags=['122', '123']) assert_containers([], res)
def test_fetch_state_normalises_container_images(self): g = Gantry() _, _, containers = g.fetch_state("foo") containers = sorted(containers, key=lambda x: x["Id"]) for im, ct in zip(["1355", "e79a", "e79a", "e79a"], containers): assert_equal(64, len(ct["Image"])) assert_equal(im, ct["Image"][:4])
def test_fetch_state_normalises_container_images(self): g = Gantry() _, _, containers = g.fetch_state('foo') containers = sorted(containers, key=lambda x: x['Id']) for im, ct in zip(['1355', 'e79a', 'e79a', 'e79a'], containers): assert_equal(64, len(ct['Image'])) assert_equal(im, ct['Image'][:4])
def test_containers_tags(self): g = Gantry() res = g.containers('foo', tags=['123']) assert_containers(['1da4', '5e68', '6000'], res) res = g.containers('foo', tags=['123', 'latest']) assert_containers(['1da4', '5e68', '6000'], res) res = g.containers('foo', tags=['122', '123']) assert_containers(['1da4', '5e68', '6000', '0ed4'], res)
def test_containers_tags(self): g = Gantry() res = g.containers("foo", tags=["123"]) assert_containers(["1da4", "5e68", "6000"], res) res = g.containers("foo", tags=["123", "latest"]) assert_containers(["1da4", "5e68", "6000"], res) res = g.containers("foo", tags=["122", "123"]) assert_containers(["1da4", "5e68", "6000", "0ed4"], res)
def test_deploy(self, start_mock): start_mock.return_value = 0 g = Gantry() g.deploy("foo", "124", "123") self.docker_mock.stop.assert_called_once_with( "1da4dfe2db6dbf45755f8419e9de4e78f340b4f300783a57e42ead853b46158a", "5e68d8d416da617eeed45f7613f820731fe1d642ff343a43a4a49b55cbb2116e", "60008cffafabaca08174af02d95de22bda6aad09a31a86aeb6b47a6c77f3bec3", ) start_mock.assert_called_with("51f59b5c1b8354c2cc430cc3641fc87a0ad8443465f7b97d9f79ad6263f45548") assert_equal(3, start_mock.call_count)
def test_deploy(self, start_mock): start_mock.return_value = 0 g = Gantry() g.deploy('foo', '124', '123') self.docker_mock.stop.assert_called_once_with( '1da4dfe2db6dbf45755f8419e9de4e78f340b4f300783a57e42ead853b46158a', '5e68d8d416da617eeed45f7613f820731fe1d642ff343a43a4a49b55cbb2116e', '60008cffafabaca08174af02d95de22bda6aad09a31a86aeb6b47a6c77f3bec3') start_mock.assert_called_with( '51f59b5c1b8354c2cc430cc3641fc87a0ad8443465f7b97d9f79ad6263f45548') assert_equal(3, start_mock.call_count)
def test_fetch_state_images_tags(self): g = Gantry() images, tags, _ = g.fetch_state('foo') assert_equal(4, len(images)) assert_equal(['122', '123', '124', 'latest'], sorted(tags)) assert_equal(tags['124'], tags['latest'])
def test_containers_all(self): g = Gantry() res = g.containers("foo") assert_containers(["1da4", "5e68", "6000", "0ed4"], res)
def test_containers_all(self): g = Gantry() res = g.containers('foo') assert_containers(['1da4', '5e68', '6000', '0ed4'], res)
def test_fetch_state_images_tags(self): g = Gantry() images, tags, _ = g.fetch_state("foo") assert_equal(4, len(images)) assert_equal(["122", "123", "124", "latest"], sorted(tags)) assert_equal(tags["124"], tags["latest"])
def test_ports(self): g = Gantry() assert_equal([[12345, 8000], [12346, 8000], [12347, 8001]], g.ports("foo", tags=["123"])) assert_equal([], g.ports("bar", tags=["abc"])) assert_equal([], g.ports("bar", tags=["cde"]))
def test_deploy_unknown_from_tag(self, start_mock): start_mock.return_value = 0 g = Gantry() # Should not raise g.deploy("foo", "124", "122")
def test_deploy_stop(self, start_mock): start_mock.return_value = 0 g = Gantry() g.deploy("foo", "124", "123", stop=False) self.docker_mock.stop.assert_not_called()
def test_deploy_stop(self, start_mock): start_mock.return_value = 0 g = Gantry() g.deploy('foo', '124', '123', stop=False) self.docker_mock.stop.assert_not_called()
def test_deploy_error(self, start_mock): start_mock.return_value = 1 g = Gantry() assert_raises(GantryError, g.deploy, 'foo', '124', '123')
def test_deploy_unknown_from_tag(self, start_mock): start_mock.return_value = 0 g = Gantry() # Should not raise g.deploy('foo', '124', '122')
def test_deploy_unknown_to_tag(self): g = Gantry() assert_raises(GantryError, g.deploy, 'foo', '125', '123')