def test_auth_provider_add_user(self): mock_dds_user = Mock() dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.auth_provider_add_user.return_value.json.return_value = mock_dds_user dds_util._remote_store = mock_remote_store dds_user = dds_util.auth_provider_add_user(auth_provider_id='provider1', username='******') self.assertEqual(dds_user, mock_dds_user) mock_remote_store.data_service.auth_provider_add_user.assert_called_with('provider1', 'user1')
def test_get_auth_provider(self): mock_provider = Mock(name='provider1') dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.get_auth_provider.return_value.json.return_value = mock_provider dds_util._remote_store = mock_remote_store provider = dds_util.get_auth_provider('provider1') self.assertEqual(provider, mock_provider) mock_remote_store.data_service.get_auth_provider.assert_called_with('provider1')
def test_get_auth_provider_affiliates(self): mock_affiliate = Mock(id='affiliate1') dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.get_auth_provider_affiliates.return_value.json.return_value = [mock_affiliate] dds_util._remote_store = mock_remote_store affiliates = dds_util.get_auth_provider_affiliates('provider1', full_name_contains='Joe') self.assertEqual(affiliates, [mock_affiliate]) mock_remote_store.data_service.get_auth_provider_affiliates.assert_called_with('provider1', 'Joe', None, None)
def test_get_users_no_filter(self): mock_user = Mock(name='joe') dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.get_users.return_value = [mock_user] dds_util._remote_store = mock_remote_store users = dds_util.get_users() self.assertEqual(users, [mock_user]) mock_remote_store.data_service.get_users.assert_called_with(None, None, None)
def test_get_users_with_filters(self): mock_user = Mock(name='joe') dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.get_users.return_value = [mock_user] dds_util._remote_store = mock_remote_store users = dds_util.get_users(full_name_contains='Joe', email='*****@*****.**', username='******') self.assertEqual(users, [mock_user]) mock_remote_store.data_service.get_users.assert_called_with('Joe', '*****@*****.**', 'joe')
def test_get_auth_provider(self): mock_provider = Mock(name='provider1') dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.get_auth_provider.return_value.json.return_value = mock_provider dds_util._remote_store = mock_remote_store provider = dds_util.get_auth_provider('provider1') self.assertEqual(provider, mock_provider) mock_remote_store.data_service.get_auth_provider.assert_called_with( 'provider1')
def test_get_users_no_filter(self): mock_user = Mock(name='joe') dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.get_users.return_value = [mock_user] dds_util._remote_store = mock_remote_store users = dds_util.get_users() self.assertEqual(users, [mock_user]) mock_remote_store.data_service.get_users.assert_called_with( None, None, None)
def test_auth_provider_add_user(self): mock_dds_user = Mock() dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.auth_provider_add_user.return_value.json.return_value = mock_dds_user dds_util._remote_store = mock_remote_store dds_user = dds_util.auth_provider_add_user( auth_provider_id='provider1', username='******') self.assertEqual(dds_user, mock_dds_user) mock_remote_store.data_service.auth_provider_add_user.assert_called_with( 'provider1', 'user1')
def test_get_project_children(self): dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() dds_util._remote_store = mock_remote_store mock_children = [Mock()] mock_remote_store.data_service.get_project_children.return_value = mock_children children = dds_util.get_project_children('123') self.assertEqual(children, mock_children) self.assertEqual( mock_remote_store.data_service.get_project_children.call_args, call('123', ''))
def test_get_user_project_permission(self): dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.get_user_project_permission.return_value.json.return_value = { 'auth_role': { 'id': PROJECT_ADMIN_ID } } dds_util._remote_store = mock_remote_store resp = dds_util.get_user_project_permission(project_id='123', user_id='456') self.assertEqual(resp['auth_role']['id'], PROJECT_ADMIN_ID) mock_remote_store.data_service.get_user_project_permission.assert_called_with('123', '456')
def test_get_users_with_filters(self): mock_user = Mock(name='joe') dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.get_users.return_value = [mock_user] dds_util._remote_store = mock_remote_store users = dds_util.get_users(full_name_contains='Joe', email='*****@*****.**', username='******') self.assertEqual(users, [mock_user]) mock_remote_store.data_service.get_users.assert_called_with( 'Joe', '*****@*****.**', 'joe')
def test_get_auth_provider_affiliates(self): mock_affiliate = Mock(id='affiliate1') dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.get_auth_provider_affiliates.return_value.json.return_value = [ mock_affiliate ] dds_util._remote_store = mock_remote_store affiliates = dds_util.get_auth_provider_affiliates( 'provider1', full_name_contains='Joe') self.assertEqual(affiliates, [mock_affiliate]) mock_remote_store.data_service.get_auth_provider_affiliates.assert_called_with( 'provider1', 'Joe', None, None)
def test_get_project_permissions(self): dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() mock_remote_store.data_service.get_project_permissions.return_value.json.return_value = { 'auth_role': { 'id': PROJECT_ADMIN_ID } } dds_util._remote_store = mock_remote_store resp = dds_util.get_project_permissions(project_id='123') self.assertEqual(resp['auth_role']['id'], PROJECT_ADMIN_ID) mock_remote_store.data_service.get_project_permissions.assert_called_with( '123')
def test_cancel_project_transfer(self): dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() dds_util._remote_store = mock_remote_store dds_util.cancel_project_transfer(transfer_id='123')