def test_get_image_meta(self): client = apiclient.Client() client.get_image_meta('sf-2') self.mock_request.assert_called_with('GET', 'http://localhost:13000/images', data={'node': 'sf-2'})
def test_cache_image(self): client = apiclient.Client() client.cache_image('imageurl') self.mock_request.assert_called_with('POST', 'http://localhost:13000/images', data={'url': 'imageurl'})
def test_unpause_instance(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.unpause_instance('notreallyauuid') self.mock_request.assert_called_with( 'POST', '/instances/notreallyauuid/unpause')
def test_create_instance_user_data(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://*****:*****@cirros'], 'sshkey', 'userdatabeforebase64', namespace=None, force_placement=None, video={ 'model': 'cirrus', 'memory': 16384 }) self.mock_request.assert_called_with('POST', '/instances', data={ 'name': 'foo', 'cpus': 1, 'memory': 2048, 'network': ['netuuid1'], 'disk': ['8@cirros'], 'ssh_key': 'sshkey', 'user_data': 'userdatabeforebase64', 'namespace': None, 'video': { 'memory': 16384, 'model': 'cirrus' } })
def test_create_instance(self): client = apiclient.Client() client.create_instance('foo', 1, 2048, ['netuuid1'], ['8@cirros'], 'sshkey', None, namespace=None, force_placement=None, video={ 'model': 'cirrus', 'memory': 16384 }) self.mock_request.assert_called_with( 'POST', 'http://*****:*****@cirros'], 'ssh_key': 'sshkey', 'user_data': None, 'namespace': None, 'video': { 'memory': 16384, 'model': 'cirrus' } })
def test_get_namespace_metadata(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.get_namespace_metadata('testspace') self.mock_request.assert_called_with( 'GET', '/auth/namespaces/testspace/metadata')
def test_delete_network(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.delete_network('notreallyauuid') self.mock_request.assert_called_with('DELETE', '/networks/notreallyauuid')
def test_delete_namespace_metadata_item(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.delete_namespace_metadata_item('testspace', 'billy') self.mock_request.assert_called_with( 'DELETE', '/auth/namespaces/testspace/metadata/billy')
def test_delete_namespace_key(self): client = apiclient.Client() client.delete_namespace_key('testspace', 'keyname') self.mock_request.assert_called_with( 'DELETE', 'http://localhost:13000/auth/namespaces/testspace/keys/keyname')
def test_hard_reboot_instance(self): client = apiclient.Client() client.reboot_instance('notreallyauuid', hard=True) self.mock_request.assert_called_with( 'POST', 'http://localhost:13000/instances/notreallyauuid/reboothard')
def test_delete_instance_metadata_item(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.delete_instance_metadata_item('instance1', 'petname') self.mock_request.assert_called_with( 'DELETE', '/instances/instance1/metadata/petname')
def test_snapshot_instance(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.snapshot_instance('notreallyauuid', all=True) self.mock_request.assert_called_with( 'POST', '/instances/notreallyauuid/snapshot', data={'all': True})
def test_get_instance_interfaces(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.get_instance_interfaces('notreallyauuid') self.mock_request.assert_called_with( 'GET', '/instances/notreallyauuid/interfaces')
def test_delete_network_metadata_item(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.delete_network_metadata_item('net1', 'herd') self.mock_request.assert_called_with('DELETE', '/networks/net1/metadata/herd')
def test_get_instance_interfaces(self): client = apiclient.Client() client.get_instance_interfaces('notreallyauuid') self.mock_request.assert_called_with( 'GET', 'http://localhost:13000/instances/notreallyauuid/interfaces')
def test_get_networks(self): client = apiclient.Client() client.get_networks() self.mock_request.assert_called_with('GET', 'http://localhost:13000/networks', data={'all': False})
def test_delete_instance_metadata_item(self): client = apiclient.Client() client.delete_instance_metadata_item('instance1', 'petname') self.mock_request.assert_called_with( 'DELETE', 'http://localhost:13000/instances/instance1/metadata/petname')
def test_delete_namespace_metadata_item(self): client = apiclient.Client() client.delete_namespace_metadata_item('testspace', 'billy') self.mock_request.assert_called_with( 'DELETE', 'http://localhost:13000/auth/namespaces/testspace/metadata/billy')
def test_create_namespace(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.create_namespace('testspace') self.mock_request.assert_called_with('POST', '/auth/namespaces', data={'namespace': 'testspace'})
def test_cache_image(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.cache_image('imageurl') self.mock_request.assert_called_with('POST', '/images', data={'url': 'imageurl'})
def test_set_namespace_metadata_item(self): client = apiclient.Client() client.set_namespace_metadata_item('testspace', 'billy', 'bob') self.mock_request.assert_called_with( 'PUT', 'http://localhost:13000/auth/namespaces/testspace/metadata/billy', data={'value': 'bob'})
def _make_namespace(self, name, key): self._remove_namespace(name) self.system_client.create_namespace(name) self.system_client.add_namespace_key(name, 'test', key) return apiclient.Client(base_url=self.system_client.base_url, namespace=name, key=key)
def test_get_images(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.get_images('sf-2') self.mock_request.assert_called_with('GET', '/images', data={'node': 'sf-2'})
def test_snapshot_instance(self): client = apiclient.Client() client.snapshot_instance('notreallyauuid', all=True) self.mock_request.assert_called_with( 'POST', 'http://localhost:13000/instances/notreallyauuid/snapshot', data={'all': True})
def test_create_namespace(self): client = apiclient.Client() client.create_namespace('testspace') self.mock_request.assert_called_with( 'POST', 'http://localhost:13000/auth/namespaces', data={'namespace': 'testspace'})
def test_get_networks(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.get_networks() self.mock_request.assert_called_with('GET', '/networks', data={'all': False})
def test_set_namespace_metadata_item(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.set_namespace_metadata_item('testspace', 'billy', 'bob') self.mock_request.assert_called_with( 'PUT', '/auth/namespaces/testspace/metadata/billy', data={'value': 'bob'})
def test_delete_all_networks_namespace(self): client = apiclient.Client() client.delete_all_networks('bobspace') self.mock_request.assert_called_with('DELETE', 'http://localhost:13000/networks', data={ 'confirm': True, 'namespace': 'bobspace' })
def test_delete_all_networks_namespace(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.delete_all_networks('bobspace') self.mock_request.assert_called_with('DELETE', '/networks', data={ 'confirm': True, 'namespace': 'bobspace' })
def test_add_namespace_key(self): client = apiclient.Client(suppress_configuration_lookup=True, base_url='http://localhost:13000') client.add_namespace_key('testspace', 'testkeyname', 'secretkey') self.mock_request.assert_called_with('POST', '/auth/namespaces/testspace/keys', data={ 'key_name': 'testkeyname', 'key': 'secretkey' })