def test_push_repository_bad_return_code(self):
        mock_conn = self.mox.CreateMockAnything()

        body = '{"username":"******","password":"******",' '"auth":"","email":"*****@*****.**"}'
        mock_conn.request("POST", "/v1.4/images/ping/push", headers={"Content-Type": "application/json"}, body=body)
        response = FakeResponse(400, headers={"Content-Type": "application/json"})
        mock_conn.getresponse().AndReturn(response)

        self.mox.ReplayAll()

        client = nova.virt.docker.client.DockerHTTPClient(mock_conn)
        self.assertEqual(False, client.push_repository("ping"))

        self.mox.VerifyAll()
Beispiel #2
0
    def test_push_repository(self):
        mock_conn = self.mox.CreateMockAnything()

        body = ('{"username":"******","password":"******",'
                '"auth":"","email":"*****@*****.**"}')
        mock_conn.request('POST', '/v1.4/images/ping/push',
                          headers={'Content-Type': 'application/json'},
                          body=body)
        response = FakeResponse(200,
                                headers={'Content-Type': 'application/json'})
        mock_conn.getresponse().AndReturn(response)

        self.mox.ReplayAll()

        client = nova.virt.docker.client.DockerHTTPClient(mock_conn)
        self.assertEqual(True, client.push_repository('ping'))

        self.mox.VerifyAll()
Beispiel #3
0
    def test_push_repository_bad_return_code(self):
        mock_conn = self.mox.CreateMockAnything()

        body = ('{"username":"******","password":"******",'
                '"auth":"","email":"*****@*****.**"}')
        mock_conn.request('POST', '/v1.4/images/ping/push',
                          headers={'Content-Type': 'application/json'},
                          body=body)
        response = FakeResponse(400,
                                headers={'Content-Type': 'application/json'})
        mock_conn.getresponse().AndReturn(response)

        self.mox.ReplayAll()

        client = nova.virt.docker.client.DockerHTTPClient(mock_conn)
        self.assertEqual(False, client.push_repository('ping'))

        self.mox.VerifyAll()