def test_get_entities(self, service_name): identity_service = self.mock_identity.return_value fake_project = identity_service.create_project.return_value fake_user = identity_service.create_user.return_value fake_role = identity_service.create_role.return_value fake_service = identity_service.create_service.return_value scenario = basic.GetEntities(self.context) scenario.run(service_name) identity_service.create_project.assert_called_once_with() identity_service.create_user.assert_called_once_with( project_id=fake_project.id) identity_service.create_role.assert_called_once_with() identity_service.get_project.assert_called_once_with(fake_project.id) identity_service.get_user.assert_called_once_with(fake_user.id) identity_service.get_role.assert_called_once_with(fake_role.id) if service_name is None: identity_service.create_service.assert_called_once_with() self.assertFalse(identity_service.get_service_by_name.called) identity_service.get_service.assert_called_once_with( fake_service.id) else: identity_service.get_service_by_name.assert_called_once_with( service_name) self.assertFalse(identity_service.create_service.called) identity_service.get_service.assert_called_once_with( identity_service.get_service_by_name.return_value.id)
def test_get_entities(self, service_name): fake_tenant = mock.MagicMock() fake_user = mock.MagicMock() fake_role = mock.MagicMock() fake_service = mock.MagicMock() self.mock_identity.return_value.create_role.return_value = fake_role scenario = basic.GetEntities(self.context) scenario._tenant_create = mock.MagicMock(return_value=fake_tenant) scenario._user_create = mock.MagicMock(return_value=fake_user) scenario._service_create = mock.MagicMock(return_value=fake_service) scenario._get_tenant = mock.MagicMock(return_value=fake_tenant) scenario._get_user = mock.MagicMock(return_value=fake_user) scenario._get_role = mock.MagicMock(return_value=fake_role) scenario._get_service_by_name = mock.MagicMock( return_value=fake_service) scenario._get_service = mock.MagicMock(return_value=fake_service) scenario.run(service_name) scenario._tenant_create.assert_called_once_with() scenario._user_create.assert_called_once_with() self.mock_identity.return_value.create_role.assert_called_once_with() scenario._get_tenant.assert_called_once_with(fake_tenant.id) scenario._get_user.assert_called_once_with(fake_user.id) scenario._get_role.assert_called_once_with(fake_role.id) if service_name is None: scenario._service_create.assert_called_once_with() self.assertFalse(scenario._get_service_by_name.called) else: scenario._get_service_by_name.assert_called_once_with(service_name) self.assertFalse(scenario._service_create.called) scenario._get_service.assert_called_once_with(fake_service.id)