def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.contributor = UserF.create() self.project = ProjectF.create(add_admins=[self.admin], add_contributors=[self.contributor])
def post(self, user, data=None): if user.is_anonymous and not User.objects.filter( display_name='AnonymousUser').exists(): UserF.create(display_name='AnonymousUser') if data is None: data = { 'name': 'A test image', 'description': 'Test image description', 'file': get_image() } url = reverse( 'api:project_media', kwargs={ 'project_id': self.project.id, 'contribution_id': self.contribution.id } ) request = self.factory.post(url, data) force_authenticate(request, user) view = AllContributionsMediaAPIView.as_view() return view( request, project_id=self.project.id, contribution_id=self.contribution.id ).render()
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.contributor = UserF.create() self.view_member = UserF.create() self.non_member = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.contributor], add_viewers=[self.view_member] ) self.other_project = ProjectF.create() # Create 20 locations, 10 should be accessible for the project for x in range(0, 5): LocationFactory() LocationFactory(**{ 'private': True, 'private_for_project': self.other_project }) LocationFactory(**{ 'private': True, 'private_for_project': self.project }) LocationFactory(**{ 'private': True })
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.creator = UserF.create() self.viewer = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.creator] ) self.contribution = ObservationFactory.create( **{'project': self.project, 'creator': self.creator} ) self.viewer = UserF.create() self.grouping = GroupingFactory.create( add_viewers=[self.viewer], **{'project': self.project} ) RuleFactory.create(**{ 'grouping': self.grouping, 'category': self.contribution.category }) self.image_file = ImageFileFactory.create( **{'contribution': self.contribution, 'creator': self.creator} )
def setUp(self): self.contributor = UserF.create() self.admin = UserF.create() self.non_member = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.contributor] ) self.observation = ObservationFactory.create(**{ 'project': self.project, 'creator': self.contributor }) comment = CommentFactory.create(**{ 'commentto': self.observation }) response = CommentFactory.create(**{ 'commentto': self.observation, 'respondsto': comment }) CommentFactory.create(**{ 'commentto': self.observation, 'respondsto': response }) CommentFactory.create(**{ 'commentto': self.observation, 'respondsto': comment }) CommentFactory.create(**{ 'commentto': self.observation })
def setUp(self): self.admin = UserF.create() self.contributor = UserF.create() self.view_member = UserF.create() self.non_member = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.contributor], add_viewers=[self.view_member] ) self.category = CategoryFactory(**{ 'status': 'active', 'project': self.project }) TextFieldFactory.create(**{ 'key': 'key_1', 'category': self.category, 'order': 0 }) NumericFieldFactory.create(**{ 'key': 'key_2', 'category': self.category, 'order': 1 })
def setUp(self): self.contributor = UserF.create() self.admin = UserF.create() self.non_member = UserF.create() self.project = ProjectF(add_admins=[self.admin], add_contributors=[self.contributor]) self.observation = ObservationFactory.create( **{ 'project': self.project, 'creator': self.contributor }) comment = CommentFactory.create(**{'commentto': self.observation}) response = CommentFactory.create(**{ 'commentto': self.observation, 'respondsto': comment }) CommentFactory.create(**{ 'commentto': self.observation, 'respondsto': response }) CommentFactory.create(**{ 'commentto': self.observation, 'respondsto': comment }) CommentFactory.create(**{'commentto': self.observation})
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.creator = UserF.create() self.viewer = UserF.create() self.project = ProjectF(add_admins=[self.admin], add_contributors=[self.creator]) self.contribution = ObservationFactory.create(**{ 'project': self.project, 'creator': self.creator }) self.viewer = UserF.create() self.grouping = GroupingFactory.create(add_viewers=[self.viewer], **{'project': self.project}) RuleFactory.create(**{ 'grouping': self.grouping, 'category': self.contribution.category }) self.image_file = ImageFileFactory.create(**{ 'contribution': self.contribution, 'creator': self.creator })
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.creator = UserF.create() self.moderator = UserF.create() self.commenter = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.creator, self.commenter]) self.moderators = UserGroupF(add_users=[self.moderator], **{ 'project': self.project, 'can_moderate': True }) self.observation = ObservationFactory.create(**{ 'project': self.project, 'creator': self.creator, 'status': 'review' }) self.comment = CommentFactory.create( **{ 'commentto': self.observation, 'creator': self.commenter, 'review_status': 'open' })
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.creator = UserF.create() self.project = ProjectF(add_admins=[self.admin], add_contributors=[self.creator]) self.contribution = ObservationFactory.create( **{'project': self.project})
def setUp(self): self.admin = UserF.create() self.creator = UserF.create() self.project = ProjectF(add_admins=[self.admin], add_contributors=[self.creator]) self.observation = ObservationFactory.create(**{ 'project': self.project, 'creator': self.creator })
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.contributor = UserF.create() self.project = ProjectF.create( add_admins=[self.admin], add_contributors=[self.contributor] )
def setUp(self): self.user1 = UserF.create() self.user2 = UserF.create() self.app1 = ApplicationFactory(**{'user': self.user1}) self.app2 = ApplicationFactory(**{'user': self.user1}) self.app3 = ApplicationFactory(**{'user': self.user2}) self.deleted_app = ApplicationFactory(**{ 'user': self.user1, 'status': 'deleted' })
def setUp(self): self.admin = UserF.create() self.creator = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.creator] ) self.observation = ObservationFactory.create(**{ 'project': self.project, 'creator': self.creator })
def setUp(self): self.admin = UserF.create() self.view_user = UserF.create() self.project = ProjectF(add_admins=[self.admin], **{'isprivate': False}) self.private_view = GroupingFactory(add_viewers=[self.view_user], **{'project': self.project}) self.public_view = GroupingFactory(add_viewers=[self.view_user], **{ 'project': self.project, 'isprivate': False })
def setUp(self): self.admin = UserF.create() self.contributor = UserF.create() self.view1_user = UserF.create() self.view2_user = UserF.create() self.non_member = UserF.create() self.project = ProjectF(add_admins=[self.admin], add_contributors=[self.contributor]) self.view1 = GroupingFactory(add_viewers=[self.view1_user], **{'project': self.project}) self.view2 = GroupingFactory(add_viewers=[self.view2_user], **{'project': self.project})
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.creator = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.creator] ) self.contribution = ObservationFactory.create( **{'project': self.project} )
def setUp(self): self.contributor = UserF.create() self.admin = UserF.create() self.non_member = UserF.create() self.project = ProjectF(add_admins=[self.admin], add_contributors=[self.contributor], **{'isprivate': False}) self.observation = ObservationFactory.create( **{ 'project': self.project, 'creator': self.contributor })
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.contributor = UserF.create() self.non_member = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.contributor] ) self.category = CategoryFactory(**{ 'status': 'active', 'project': self.project }) TextFieldFactory.create(**{ 'key': 'key_1', 'category': self.category, 'required': True, 'order': 1 }) NumericFieldFactory.create(**{ 'key': 'key_2', 'category': self.category, 'minval': 0, 'maxval': 1000, 'order': 2 }) self.data = { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -0.13404607772827148, 51.52439200896907 ] }, "properties": { "key_1": "value 1", "key_2": 12 }, "meta": { "category": self.category.id, }, "location": { "name": "UCL", "description": "UCL's main quad", "private": True } }
def setUp(self): self.contributor = UserF.create() self.admin = UserF.create() self.non_member = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.contributor], **{'isprivate': False} ) self.observation = ObservationFactory.create(**{ 'project': self.project, 'creator': self.contributor })
def test_get_isowner(self): user = UserF.create() comment = CommentFactory.create(**{'creator': user}) serializer = CommentSerializer(comment, context={'user': user}) self.assertTrue(serializer.get_isowner(comment)) serializer = CommentSerializer(comment, context={'user': UserF.create()}) self.assertFalse(serializer.get_isowner(comment)) serializer = CommentSerializer(comment, context={'user': AnonymousUser()}) self.assertFalse(serializer.get_isowner(comment))
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.creator = UserF.create() self.viewer = UserF.create() self.project = ProjectF(add_admins=[self.admin], add_contributors=[self.creator]) self.contribution = ObservationFactory.create(**{ 'project': self.project, 'creator': self.creator }) ImageFileFactory.create_batch(5, **{'contribution': self.contribution})
def test_get_isowner(self): user = UserF.create() comment = CommentFactory.create(**{'creator': user}) serializer = CommentSerializer(comment, context={'user': user}) self.assertTrue(serializer.get_isowner(comment)) serializer = CommentSerializer( comment, context={'user': UserF.create()}) self.assertFalse(serializer.get_isowner(comment)) serializer = CommentSerializer( comment, context={'user': AnonymousUser()}) self.assertFalse(serializer.get_isowner(comment))
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.contributor = UserF.create() self.view_member = UserF.create() self.non_member = UserF.create() self.project = ProjectF(add_admins=[self.admin], add_contributors=[self.contributor]) self.location = LocationFactory(**{ 'private': True, 'private_for_project': self.project })
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.contributor = UserF.create() self.non_member = UserF.create() self.project = ProjectF(add_admins=[self.admin], add_contributors=[self.contributor]) self.category = CategoryFactory(**{ 'status': 'active', 'project': self.project }) TextFieldFactory.create( **{ 'key': 'key_1', 'category': self.category, 'required': True, 'order': 1 }) NumericFieldFactory.create( **{ 'key': 'key_2', 'category': self.category, 'minval': 0, 'maxval': 1000, 'order': 2 }) self.data = { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-0.13404607772827148, 51.52439200896907] }, "properties": { "key_1": "value 1", "key_2": 12 }, "meta": { "category": self.category.id, }, "location": { "name": "UCL", "description": "UCL's main quad", "private": True } }
def _post(self, data, user): if user.is_anonymous and not User.objects.filter( display_name='AnonymousUser').exists(): UserF.create(display_name='AnonymousUser') url = reverse( 'api:project_observations', kwargs={ 'project_id': self.project.id } ) request = self.factory.post( url, json.dumps(data), content_type='application/json') force_authenticate(request, user=user) view = ProjectObservations.as_view() return view(request, project_id=self.project.id).render()
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.creator = UserF.create() self.viewer = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.creator] ) self.contribution = ObservationFactory.create( **{'project': self.project, 'creator': self.creator} ) ImageFileFactory.create_batch(5, **{'contribution': self.contribution})
def test_access_fields_with_non_member(self): user = UserF.create() project = ProjectF.create(**{'isprivate': True}) category = CategoryFactory(**{'project': project, 'status': 'active'}) TextFieldFactory.create(**{'status': 'active', 'category': category}) TextFieldFactory.create(**{'status': 'inactive', 'category': category}) Field.objects.get_list(user, project.id, category.id)
def test_get_with_user(self): view = ApplicationOverview.as_view() url = reverse('admin:app_overview') request = APIRequestFactory().get(url) request.user = UserF.create() response = view(request).render() self.assertEqual(response.status_code, 200)
def setUp(self): self.user1 = UserF.create() self.user2 = UserF.create() self.app1 = ApplicationFactory(**{ 'user': self.user1 }) self.app2 = ApplicationFactory(**{ 'user': self.user1 }) self.app3 = ApplicationFactory(**{ 'user': self.user2 }) self.deleted_app = ApplicationFactory(**{ 'user': self.user1, 'status': 'deleted' })
def test_get_with_unconnected_user(self): view = ApplicationDisconnect.as_view() url = reverse('admin:app_disconnect', kwargs={'app_id': self.app.id}) request = APIRequestFactory().get(url) request.user = UserF.create() response = view(request, app_id=self.app.id) self.assertTrue(isinstance(response, HttpResponseRedirect))
def test_post_with_user(self): data = { 'name': 'test app', 'description': '', 'download_url': 'http://example.com/download', 'redirect_uris': 'http://example.com/redirect', 'authorization_grant_type': 'password' } view = ApplicationSettings.as_view() url = reverse('admin:app_settings', kwargs={'app_id': self.app.id}) request = APIRequestFactory().post(url, data) request.user = UserF.create() response = view(request, app_id=self.app.id).render() self.assertEqual(response.status_code, 200) self.assertContains( response, 'You are not the owner of this application and therefore not ' 'allowed to access this app.' ) ref = Application.objects.get(pk=self.app.id) self.assertNotEqual(ref.name, data.get('name')) self.assertNotEqual(ref.description, data.get('description')) self.assertNotEqual(ref.download_url, data.get('download_url')) self.assertNotEqual(ref.redirect_uris, data.get('redirect_uris')) self.assertNotEqual( ref.authorization_grant_type, data.get('authorization_grant_type') )
def test_get_with_user(self): view = ApplicationOverview.as_view() url = reverse('admin:app_overview') request = APIRequestFactory().get(url) request.user = UserF.create() response = view(request).render() self.assertEqual(response.status_code, 200)
def test_get_with_unconnected_user(self): view = ApplicationDisconnect.as_view() url = reverse('admin:app_disconnect', kwargs={'app_id': self.app.id}) request = APIRequestFactory().get(url) request.user = UserF.create() response = view(request, app_id=self.app.id) self.assertTrue(isinstance(response, HttpResponseRedirect))
def test(self): admin = UserF.create() project = ProjectF(add_admins=[admin]) observation = ObservationFactory.create(**{ 'project': project }) comment = CommentFactory.create() factory = APIRequestFactory() request = factory.post( '/api/projects/%s/observations/%s/comments/' % (project.id, observation.id), { 'text': 'Response to a comment', 'respondsto': comment.id } ) force_authenticate(request, user=admin) view = AllContributionsCommentsAPIView.as_view() response = view( request, project_id=project.id, observation_id=observation.id ).render() self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual( json.loads(response.content).get('error'), 'The comment you try to respond to is not a comment to the ' 'observation.' )
def test_post_with_user(self): data = { 'name': 'test app', 'description': '', 'download_url': 'http://example.com/download', 'redirect_uris': 'http://example.com/redirect', 'authorization_grant_type': 'password' } view = ApplicationSettings.as_view() url = reverse('admin:app_settings', kwargs={'app_id': self.app.id}) request = APIRequestFactory().post(url, data) request.user = UserF.create() response = view(request, app_id=self.app.id).render() self.assertEqual(response.status_code, 200) self.assertContains( response, 'You are not the owner of this application and therefore not ' 'allowed to access this app.' ) ref = Application.objects.get(pk=self.app.id) self.assertNotEqual(ref.name, data.get('name')) self.assertNotEqual(ref.description, data.get('description')) self.assertNotEqual(ref.download_url, data.get('download_url')) self.assertNotEqual(ref.redirect_uris, data.get('redirect_uris')) self.assertNotEqual( ref.authorization_grant_type, data.get('authorization_grant_type') )
def test_delete_with_user(self): user = UserF.create() view = RuleDelete.as_view() project = ProjectF.create(add_contributors=[user]) grouping = GroupingFactory.create(**{'project': project}) rule = RuleFactory.create(**{'grouping': grouping}) url = reverse( 'admin:rule_delete', kwargs={ 'project_id': project.id, 'grouping_id': grouping.id, 'rule_id': rule.id } ) request = APIRequestFactory().get(url) request.user = user response = view( request, project_id=project.id, grouping_id=grouping.id, rule_id=rule.id).render() self.assertEqual(response.status_code, 200) self.assertEqual(Rule.objects.count(), 1) self.assertContains( response, 'You are not member of the administrators group of this project ' 'and therefore not allowed to alter the settings of the project' )
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.contributor = UserF.create() self.view_member = UserF.create() self.non_member = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.contributor] ) self.location = LocationFactory(**{ 'private': True, 'private_for_project': self.project })
def test_delete_with_user(self): user = UserF.create() view = RuleDelete.as_view() project = ProjectF.create(add_contributors=[user]) grouping = GroupingFactory.create(**{'project': project}) rule = RuleFactory.create(**{'grouping': grouping}) url = reverse('admin:rule_delete', kwargs={ 'project_id': project.id, 'grouping_id': grouping.id, 'rule_id': rule.id }) request = APIRequestFactory().get(url) request.user = user response = view(request, project_id=project.id, grouping_id=grouping.id, rule_id=rule.id).render() self.assertEqual(response.status_code, 200) self.assertEqual(Rule.objects.count(), 1) self.assertContains( response, 'You are not member of the administrators group of this project ' 'and therefore not allowed to alter the settings of the project')
def test_for_moderator(self): observations = Observation.objects.all().for_moderator(UserF.create()) self.assertEqual(len(observations), 10) for observation in observations: self.assertNotIn( observation.status, ['draft', 'deleted'] )
def test_for_viewer(self): observations = Observation.objects.all().for_viewer(UserF.create()) self.assertEqual(len(observations), 5) for observation in observations: self.assertNotIn( observation.status, ['draft', 'pending', 'deleted'] )
def test_for_viewer(self): observations = Observation.objects.all().for_viewer(UserF.create()) self.assertEqual(len(observations), 5) for observation in observations: self.assertNotIn( observation.status, ['draft', 'pending', 'deleted'] )
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.contributor = UserF.create() self.non_member = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.contributor] ) self.category = CategoryFactory(**{ 'status': 'active', 'project': self.project }) TextFieldFactory.create(**{ 'key': 'key_1', 'category': self.category, 'order': 0 }) NumericFieldFactory.create(**{ 'key': 'key_2', 'category': self.category, 'order': 1 }) location = LocationFactory() self.observation = ObservationFactory.create(**{ 'properties': { "key_1": "value 1", "key_2": 12, }, 'category': self.category, 'project': self.project, 'location': location, 'creator': self.admin, 'status': 'active' }) self.update_data = { "properties": { "version": 1, "key_2": 15 } }
def test_get_list_with_non_member(self): non_member = UserF.create() views = Grouping.objects.get_list(non_member, self.project.id) self.assertEqual(len(views), 2) self.assertIn(self.view1_public, views) self.assertIn(self.view2_public, views) self.assertNotIn(self.view1, views) self.assertNotIn(self.view2, views)
def test_for_moderator(self): observations = Observation.objects.all().for_moderator(UserF.create()) self.assertEqual(len(observations), 10) for observation in observations: self.assertNotIn( observation.status, ['draft', 'deleted'] )
def test_access_with_projct_non_member(self): contributor = UserF.create() project = ProjectF.create() CategoryFactory(**{'project': project, 'status': 'active'}) CategoryFactory(**{'project': project, 'status': 'inactive'}) Category.objects.get_list(contributor, project.id)
def test_admin_access_with_non_member(self): user = UserF.create() project = ProjectF.create(**{'isprivate': True}) active_type = CategoryFactory(**{'project': project}) Category.objects.as_admin(user, project.id, active_type.id)
def test_access_fields_with_admin(self): admin = UserF.create() project = ProjectF.create(add_admins=[admin], **{'isprivate': True}) category = CategoryFactory(**{'project': project, 'status': 'active'}) TextFieldFactory.create(**{'status': 'active', 'category': category}) TextFieldFactory.create(**{'status': 'inactive', 'category': category}) self.assertEqual( len(Field.objects.get_list(admin, project.id, category.id)), 2)
def get_response(self, user): if user.is_anonymous and not User.objects.filter( display_name='AnonymousUser').exists(): UserF.create(display_name='AnonymousUser') factory = APIRequestFactory() request = factory.post( '/api/projects/%s/maps/all-contributions/%s/comments/' % (self.project.id, self.observation.id), {'text': 'A comment to the observation'} ) force_authenticate(request, user=user) view = AllContributionsCommentsAPIView.as_view() return view( request, project_id=self.project.id, observation_id=self.observation.id ).render()
def test_admin_access_active_field_with_non_member(self): user = UserF.create() project = ProjectF.create(**{'isprivate': True}) category = CategoryFactory(**{'project': project, 'status': 'active'}) field = TextFieldFactory.create(**{ 'status': 'active', 'category': category }) Field.objects.as_admin(user, project.id, category.id, field.id)
def test_admin_access_with_contributor(self): user = UserF.create() project = ProjectF.create(add_contributors=[user], **{'isprivate': True}) active_type = CategoryFactory(**{'project': project}) Category.objects.as_admin(user, project.id, active_type.id)
def test_flag_with_anonymous(self): if not User.objects.filter(display_name='AnonymousUser').exists(): UserF.create(display_name='AnonymousUser') url = reverse('api:project_single_observation', kwargs={ 'project_id': self.project.id, 'observation_id': self.observation.id }) request = self.factory.patch(url) request.data = {'meta': {'status': "pending"}} request.user = AnonymousUser() view = SingleContributionAPIView() view.update_and_respond(request, self.observation) self.assertEqual( Observation.objects.get(pk=self.observation.id).status, 'active' )
def test_access_with_projct_admin(self): admin = UserF.create() project = ProjectF.create(add_admins=[admin], **{'isprivate': True}) CategoryFactory(**{'project': project, 'status': 'active'}) CategoryFactory(**{'project': project, 'status': 'inactive'}) self.assertEqual(len(Category.objects.get_list(admin, project.id)), 2)
def setUp(self): self.creator = UserF.create() ObservationFactory.create_batch( 5, **{'status': 'active', 'creator': self.creator}) ObservationFactory.create_batch( 5, **{'status': 'draft', 'creator': self.creator}) ObservationFactory.create_batch( 5, **{'status': 'pending', 'creator': self.creator}) ObservationFactory.create_batch( 5, **{'status': 'deleted', 'creator': self.creator})
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.creator = UserF.create() self.moderator = UserF.create() self.viewer = UserF.create() self.project = ProjectF(add_admins=[self.admin], add_contributors=[self.creator], add_viewer=[self.viewer]) self.moderators = UserGroupF(add_users=[self.moderator], **{ 'project': self.project, 'can_moderate': True }) self.observation = ObservationFactory.create(**{ 'project': self.project, 'creator': self.creator, 'status': 'active' })
def setUp(self): self.creator = UserF.create() ObservationFactory.create_batch( 5, **{'status': 'active', 'creator': self.creator}) ObservationFactory.create_batch( 5, **{'status': 'draft', 'creator': self.creator}) ObservationFactory.create_batch( 5, **{'status': 'pending', 'creator': self.creator}) ObservationFactory.create_batch( 5, **{'status': 'deleted', 'creator': self.creator})
def setUp(self): self.user = UserF.create() self.app = ApplicationFactory.create() self.token = AccessToken.objects.create( user=self.user, application=self.app, token='df0af6a395b4cd072445b3832e9379bfee257da0', scope=1, expires='2030-12-31T23:59:01+00:00' )
def setUp(self): self.factory = APIRequestFactory() self.admin = UserF.create() self.creator = UserF.create() self.moderator = UserF.create() self.viewer = UserF.create() self.project = ProjectF( add_admins=[self.admin], add_contributors=[self.creator], add_viewer=[self.viewer] ) self.moderators = UserGroupF(add_users=[self.moderator], **{ 'project': self.project, 'can_moderate': True }) self.observation = ObservationFactory.create(**{ 'project': self.project, 'creator': self.creator, 'status': 'active' })
def test_access_inactive_with_admin(self): admin = UserF.create() project = ProjectF.create( add_admins=[admin], **{'isprivate': True} ) inactive_type = CategoryFactory(**{ 'project': project, 'status': 'inactive' }) self.assertEqual(inactive_type, Category.objects.get_single( admin, project.id, inactive_type.id))
def test_admin_access_with_non_member(self): user = UserF.create() project = ProjectF.create(**{ 'isprivate': True }) active_type = CategoryFactory(**{ 'project': project }) Category.objects.as_admin(user, project.id, active_type.id)