예제 #1
0
    def test_inspect_container_bad_return_code(self):
        mock_conn = self.mox.CreateMockAnything()

        mock_conn.request("GET", "/v1.4/containers/XXX/json", headers={"Content-Type": "application/json"})
        response = FakeResponse(404)
        mock_conn.getresponse().AndReturn(response)

        self.mox.ReplayAll()

        client = nova.virt.docker.client.DockerHTTPClient(mock_conn)
        container = client.inspect_container("XXX")
        self.assertEqual(None, container)

        self.mox.VerifyAll()
예제 #2
0
    def test_inspect_container_bad_return_code(self):
        mock_conn = self.mox.CreateMockAnything()

        mock_conn.request('GET', '/v1.4/containers/XXX/json',
                          headers={'Content-Type': 'application/json'})
        response = FakeResponse(404)
        mock_conn.getresponse().AndReturn(response)

        self.mox.ReplayAll()

        client = nova.virt.docker.client.DockerHTTPClient(mock_conn)
        container = client.inspect_container('XXX')
        self.assertIsNone(container)

        self.mox.VerifyAll()
예제 #3
0
    def test_inspect_container_bad_return_code(self):
        mock_conn = self.mox.CreateMockAnything()

        mock_conn.request('GET', '/v1.4/containers/XXX/json',
                          headers={'Content-Type': 'application/json'})
        response = FakeResponse(404)
        mock_conn.getresponse().AndReturn(response)

        self.mox.ReplayAll()

        client = nova.virt.docker.client.DockerHTTPClient(mock_conn)
        container = client.inspect_container('XXX')
        self.assertIsNone(container)

        self.mox.VerifyAll()
예제 #4
0
    def test_inspect_container(self):
        mock_conn = self.mox.CreateMockAnything()

        mock_conn.request('GET', '/v1.4/containers/XXX/json',
                          headers={'Content-Type': 'application/json'})
        response = FakeResponse(200, data='{"id": "XXX"}',
                                headers={'Content-Type': 'application/json'})
        mock_conn.getresponse().AndReturn(response)

        self.mox.ReplayAll()

        client = nova.virt.docker.client.DockerHTTPClient(mock_conn)
        container = client.inspect_container('XXX')
        self.assertEqual({'id': 'XXX'}, container)

        self.mox.VerifyAll()
예제 #5
0
    def test_inspect_container(self):
        mock_conn = self.mox.CreateMockAnything()

        mock_conn.request('GET', '/v1.4/containers/XXX/json',
                          headers={'Content-Type': 'application/json'})
        response = FakeResponse(200, data='{"id": "XXX"}',
                                headers={'Content-Type': 'application/json'})
        mock_conn.getresponse().AndReturn(response)

        self.mox.ReplayAll()

        client = nova.virt.docker.client.DockerHTTPClient(mock_conn)
        container = client.inspect_container('XXX')
        self.assertEqual({'id': 'XXX'}, container)

        self.mox.VerifyAll()