def test_logs_container(self): response = DockerEngine().run_container_operation(operation='run', data={ 'image': 'mongo:4.2.3', 'detach': True }) self.assertNotEqual(response, None, 'Background image run failed') self.assertEqual(response.status, 'created', 'Container not created') container = DockerEngine().get_container_by_id(response.short_id) self.assertNotEqual(container, None, 'Container does not exist') response = DockerEngine().run_operation_in_object(object=container, operation='logs', data={}) self.assertIsInstance(response.decode(), str, 'Wrong container logs') response = DockerEngine().run_operation_in_object(object=container, operation='stop', data={}) self.assertEqual(response, None, 'Container not stopped')
def test_run_hello_world_container(self): response = DockerEngine().run_container_operation( operation='run', data={'image': 'hello-world'}) self.assertNotEqual(response.decode().find('Hello from Docker!'), -1, 'Hello world run failed')