def test_project_remove_permission(mock_event): """ Test removing permissions to project event """ auth_claims = { 'auth0_username_claim': 'http:/localhost/foo', 'email': '*****@*****.**', 'sub' : 'bar', 'name' : 'name' } username = '******' auth_user = AuthUser(auth_claims) auth_user.username='******' event_type = EventType.RemovePermission project_sfdc_id = 'project_sfdc_id' UserPermissions.load = Mock() UserPermissions.remove_project = Mock() UserPermissions.save = Mock() project_controller.remove_permission( auth_user, username, project_sfdc_id ) event_data = 'User {} permission removed to project {}'.format(username, project_sfdc_id) mock_event.assert_called_with( event_type=event_type, event_data=event_data, event_summary=event_data, event_project_id=project_sfdc_id, contains_pii=True, )
def test_remove_permission(mock_event, create_event_company, auth_user: AuthUser, company): """Test remove permissions """ event_type = EventType.RemoveCompanyPermission Company.load = Mock() Company.remove_company_acl = Mock() Company.save = Mock() auth_user.username = '******' company_id = company.get_company_id() username = '******' event_data = f'Removed user {username} from Company {company.get_company_name()} permissions list.' company_controller.remove_permission(auth_user, username, company_id) mock_event.assert_called_once_with( event_data=event_data, event_summary=event_data, event_company_id=company_id, event_type=event_type, contains_pii=True, )
def auth_user(): with patch.object(AuthUser, "__init__", lambda self: None): auth_user = AuthUser() yield auth_user