Skip to content

Commit 00d803b

Browse files
authored
Merge pull request #107 from bitprj/Anurag-testcases
Added test cases to test the Organization class functions
2 parents 16377d7 + 33441cf commit 00d803b

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

backend/tests/test_models.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from conduit.profile.models import UserProfile
99
from conduit.articles.models import Article, Comment
1010
from conduit.tags.models import Tags
11+
from conduit.organizations.models import Organization
1112

1213
from .factories import UserFactory
1314

@@ -179,3 +180,85 @@ def test_make_comments(self, user):
179180
assert comment1.article == article
180181
assert comment1.author == user.profile
181182
assert len(article.comments.all()) == 2
183+
184+
185+
@pytest.mark.usefixtures('db')
186+
class TestOrganization:
187+
188+
def test_add_moderator(self, user):
189+
user = user.get()
190+
organization = Organization(name="Name_of_organization", description="Description_of_organization", slug="Slug_of_organization")
191+
organization.save()
192+
193+
assert organization.add_moderator(user.profile)
194+
195+
def test_add_member(self, user):
196+
user = user.get()
197+
organization = Organization(name="Name_of_organization", description="Description_of_organization", slug="Slug_of_organization")
198+
organization.save()
199+
200+
assert organization.add_member(user.profile)
201+
202+
def test_remove_moderator(self, user):
203+
user = user.get()
204+
organization = Organization(name="Name_of_organization", description="Description_of_organization", slug="Slug_of_organization")
205+
organization.save()
206+
organization.add_member(user.profile)
207+
208+
assert organization.remove_member(user.profile)
209+
210+
211+
def test_update_slug_true(self):
212+
organization = Organization(name="Name_of_organization", description="Description_of_organization", slug="Slug_of_organization")
213+
organization.save()
214+
215+
return organization.update_slug("New Slug")
216+
217+
def test_update_slug_false(self):
218+
organization = Organization(name="Name_of_organization", description="Description_of_organization", slug="Slug_of_organization")
219+
organization.save()
220+
221+
return organization.update_slug("New Slug_of_organization")
222+
223+
def test_is_member(self, user):
224+
user = user.get()
225+
organization = Organization(name="Name_of_organization", description="Description_of_organization", slug="Slug_of_organization")
226+
organization.save()
227+
organization.add_member(user.profile)
228+
229+
assert organization.is_member(user.profile)
230+
231+
def test_moderator(self, user):
232+
user = user.get()
233+
organization = Organization(name="Name_of_organization", description="Description_of_organization", slug="Slug_of_organization")
234+
organization.save()
235+
organization.add_moderator(user.profile)
236+
237+
assert organization.moderator(user.profile)
238+
239+
def test_promote(self, user):
240+
user = user.get()
241+
organization = Organization(name="Name_of_organization", description="Description_of_organization", slug="Slug_of_organization")
242+
organization.save()
243+
organization.add_member(user.profile)
244+
245+
assert organization.promote(user.profile)
246+
247+
def test_request_review(self, user):
248+
user = user.get()
249+
organization = Organization(name="Name_of_organization", description="Description_of_organization", slug="Slug_of_organization")
250+
organization.save()
251+
article = Article(user.profile, 'title', 'some body', description='some', isPublished='True', coverImage= "Image")
252+
article.save()
253+
254+
return organization.request_review(article)
255+
256+
def test_remove_review_status(self, user):
257+
user = user.get()
258+
organization = Organization(name="Name_of_organization", description="Description_of_organization", slug="Slug_of_organization")
259+
organization.save()
260+
article = Article(user.profile, 'title', 'some body', description='some', isPublished='True', coverImage= "Image")
261+
article.save()
262+
organization.pending_articles.append(article)
263+
264+
return organization.remove_review_status(article)

0 commit comments

Comments
 (0)