def test_find_project_with_generic_exception(self): sdk_connection = mock.Mock() sdk_find_project = sdk_connection.identity.find_project exc = exceptions.HttpException() # Some value other than 403. exc.status_code = 499 sdk_find_project.side_effect = exc with testtools.ExpectedException(exceptions.HttpException): cli_identity.find_project(sdk_connection, 'project1')
def test_find_project_with_generic_exception(self): sdk_connection = mock.Mock() sdk_find_project = sdk_connection.identity.find_project exc = exceptions.HttpException() # Some value other than 403. exc.status_code = 499 sdk_find_project.side_effect = exc with testtools.ExpectedException(exceptions.HttpException): cli_identity.find_project(sdk_connection, 'project1')
def test_find_project(self): sdk_connection = mock.Mock() sdk_find_project = sdk_connection.identity.find_project sdk_find_project.return_value = mock.sentinel.project1 ret = cli_identity.find_project(sdk_connection, 'project1') self.assertEqual(mock.sentinel.project1, ret) sdk_find_project.assert_called_once_with( 'project1', ignore_missing=False, domain_id=None)
def test_find_project(self): sdk_connection = mock.Mock() sdk_find_project = sdk_connection.identity.find_project sdk_find_project.return_value = mock.sentinel.project1 ret = cli_identity.find_project(sdk_connection, 'project1') self.assertEqual(mock.sentinel.project1, ret) sdk_find_project.assert_called_once_with('project1', ignore_missing=False, domain_id=None)
def test_find_project_with_forbidden_exception(self): sdk_connection = mock.Mock() sdk_find_project = sdk_connection.identity.find_project exc = exceptions.HttpException() exc.status_code = 403 sdk_find_project.side_effect = exc ret = cli_identity.find_project(sdk_connection, 'project1') self.assertIsInstance(ret, project.Project) self.assertEqual('project1', ret.id) self.assertEqual('project1', ret.name)
def test_find_project_with_forbidden_exception(self): sdk_connection = mock.Mock() sdk_find_project = sdk_connection.identity.find_project exc = exceptions.HttpException() exc.status_code = 403 sdk_find_project.side_effect = exc ret = cli_identity.find_project(sdk_connection, 'project1') self.assertIsInstance(ret, project.Project) self.assertEqual('project1', ret.id) self.assertEqual('project1', ret.name)
def test_find_project_with_domain(self): domain1 = mock.Mock() domain1.id = 'id-domain1' sdk_connection = mock.Mock() sdk_find_domain = sdk_connection.identity.find_domain sdk_find_domain.return_value = domain1 sdk_find_project = sdk_connection.identity.find_project sdk_find_project.return_value = mock.sentinel.project1 ret = cli_identity.find_project(sdk_connection, 'project1', 'domain1') self.assertEqual(mock.sentinel.project1, ret) sdk_find_domain.assert_called_once_with( 'domain1', ignore_missing=False) sdk_find_project.assert_called_once_with( 'project1', ignore_missing=False, domain_id='id-domain1')
def test_find_project_with_domain(self): domain1 = mock.Mock() domain1.id = 'id-domain1' sdk_connection = mock.Mock() sdk_find_domain = sdk_connection.identity.find_domain sdk_find_domain.return_value = domain1 sdk_find_project = sdk_connection.identity.find_project sdk_find_project.return_value = mock.sentinel.project1 ret = cli_identity.find_project(sdk_connection, 'project1', 'domain1') self.assertEqual(mock.sentinel.project1, ret) sdk_find_domain.assert_called_once_with('domain1', ignore_missing=False) sdk_find_project.assert_called_once_with('project1', ignore_missing=False, domain_id='id-domain1')