Skip to content

Commit

Permalink
Add test cases for private project on topicmodel and summary
Browse files Browse the repository at this point in the history
  • Loading branch information
susilnem committed Jun 12, 2024
1 parent ad27b25 commit ecd9f54
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions apps/analysis/tests/test_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,13 @@ def setUp(self):
self.af = AnalysisFrameworkFactory.create()
self.project = ProjectFactory.create(analysis_framework=self.af)
self.another_project = ProjectFactory.create()
self.private_project = ProjectFactory.create(is_private=True)
# User with role
self.non_member_user = UserFactory.create()
self.readonly_member_user = UserFactory.create()
self.member_user = UserFactory.create()
self.project.add_member(self.member_user, role=self.project_role_member)
self.private_project.add_member(self.member_user, role=self.project_role_member)

def _check_status(self, obj, status):
obj.refresh_from_db()
Expand Down Expand Up @@ -264,6 +266,15 @@ def _mutation_check(minput, **kwargs):
**kwargs
)

def _private_project_mutation_check(minput, **kwargs):
return self.query_check(
self.TRIGGER_TOPIC_MODEL,
minput=minput,
mnested=['project'],
variables={'projectId': self.private_project.id},
**kwargs
)

def _query_check(_id):
return self.query_check(
self.QUERY_TOPIC_MODEL,
Expand Down Expand Up @@ -301,6 +312,10 @@ def _query_check(_id):
# Valid data
minput['analysisPillar'] = str(analysis_pillar.id)

# --- member user (error since the project is private)
self.force_login(self.member_user)
_private_project_mutation_check(minput, okay=False)

# --- member user (All good)
with self.captureOnCommitCallbacks(execute=True):
response = _mutation_check(minput, okay=True)
Expand Down Expand Up @@ -407,6 +422,15 @@ def _mutation_check(minput, **kwargs):
**kwargs
)

def _private_project_mutation_check(minput, **kwargs):
return self.query_check(
self.TRIGGER_AUTOMATIC_SUMMARY,
minput=minput,
mnested=['project'],
variables={'projectId': self.private_project.id},
**kwargs
)

def _query_check(_id):
return self.query_check(
self.QUERY_AUTOMATIC_SUMMARY,
Expand All @@ -431,6 +455,10 @@ def _query_check(_id):
self.force_login(self.member_user)
_mutation_check(minput, okay=False)

# --- member user (error since the project is private)
self.force_login(self.member_user)
_private_project_mutation_check(minput, okay=False)

minput['entriesId'] = [
str(entry.id)
for entries in [
Expand Down

0 comments on commit ecd9f54

Please sign in to comment.