def setUp(self):
        """Establish a clean test environment"""
        super(TestRegistryV1Client, self).setUp()
        db_api.get_engine()
        self.context = context.RequestContext(is_admin=True)

        self.FIXTURES = [
            self.get_fixture(
                id=UUID1,
                name='fake image #1',
                is_public=False,
                disk_format='ami',
                container_format='ami',
                size=13,
                location="swift://*****:*****@acct/container/obj.tar.0",
                properties={'type': 'kernel'}),
            self.get_fixture(id=UUID2,
                             name='fake image #2',
                             properties={},
                             size=19,
                             location="file:///tmp/glance-tests/2")
        ]
        self.destroy_fixtures()
        self.create_fixtures()
        self.client = rclient.RegistryClient("0.0.0.0")
    def test_do_request(self):
        self.client = rclient.RegistryClient("0.0.0.0")

        with patch.object(test_client.BaseClient, 'do_request',
                          return_value=FakeResponse()) as mock_do_request:
            self.client.do_request("GET", "/images")
            mock_do_request.assert_called_once_with("GET", "/images",
                                                    headers={})
Exemple #3
0
    def test_do_request(self):
        self.client = rclient.RegistryClient("0.0.0.0")

        self.mox.StubOutWithMock(test_client.BaseClient, 'do_request')
        test_client.BaseClient.do_request("GET", "/images",
                                          headers={}).AndReturn(FakeResponse())
        self.mox.ReplayAll()

        self.client.do_request("GET", "/images")

        self.mox.VerifyAll()
Exemple #4
0
    def test_do_request_with_identity_headers(self):
        identity_headers = {'foo': 'bar'}
        self.client = rclient.RegistryClient("0.0.0.0",
                                             identity_headers=identity_headers)

        self.mox.StubOutWithMock(test_client.BaseClient, 'do_request')
        test_client.BaseClient.do_request(
            "GET", "/images",
            headers=identity_headers).AndReturn(FakeResponse())
        self.mox.ReplayAll()

        self.client.do_request("GET", "/images")

        self.mox.VerifyAll()
Exemple #5
0
 def setUp(self):
     """Establish a clean test environment"""
     super(TestRegistryV1Client, self).setUp()
     db_api.setup_db_env()
     db_api.get_engine()
     self.context = context.RequestContext(is_admin=True)
     self.FIXTURES = [{
         'id': UUID1,
         'name': 'fake image #1',
         'status': 'active',
         'disk_format': 'ami',
         'container_format': 'ami',
         'is_public': False,
         'created_at': timeutils.utcnow(),
         'updated_at': timeutils.utcnow(),
         'deleted_at': None,
         'deleted': False,
         'checksum': None,
         'size': 13,
         'location': "swift://*****:*****@acct/container/obj.tar.0",
         'properties': {
             'type': 'kernel'
         }
     }, {
         'id': UUID2,
         'name': 'fake image #2',
         'status': 'active',
         'disk_format': 'vhd',
         'container_format': 'ovf',
         'is_public': True,
         'created_at': timeutils.utcnow(),
         'updated_at': timeutils.utcnow(),
         'deleted_at': None,
         'deleted': False,
         'checksum': None,
         'size': 19,
         'location': "file:///tmp/glance-tests/2",
         'properties': {}
     }]
     self.destroy_fixtures()
     self.create_fixtures()
     self.client = rclient.RegistryClient("0.0.0.0")