Merged in [15314] from rjsparks@nostrum.com:
Converted the community app tests to use factories.
- Legacy-Id: 15346
Note: SVN reference [15314] has been migrated to Git commit ae70706faf
This commit is contained in:
commit
50b546338a
|
@ -1,9 +1,10 @@
|
||||||
# -*- conf-mode -*-
|
# -*- conf-mode -*-
|
||||||
|
|
||||||
/personal/rcross/6.81.3.dev0@15262
|
/personal/rcross/6.81.3.dev0@15287
|
||||||
/personal/rcross/6.81.3.dev0@15263
|
|
||||||
/personal/rcross/6.81.3.dev0@15264
|
|
||||||
/personal/rcross/6.81.3.dev0@15265
|
/personal/rcross/6.81.3.dev0@15265
|
||||||
|
/personal/rcross/6.81.3.dev0@15264
|
||||||
|
/personal/rcross/6.81.3.dev0@15263
|
||||||
|
/personal/rcross/6.81.3.dev0@15262
|
||||||
/personal/sbirkholz/mtgreg3@14074 # reviewed with issues; feedback sent
|
/personal/sbirkholz/mtgreg3@14074 # reviewed with issues; feedback sent
|
||||||
/personal/sbirkholz/meeting_registration@13969 # manual branch merge
|
/personal/sbirkholz/meeting_registration@13969 # manual branch merge
|
||||||
/personal/sbirkholz/meeting_registration@13954
|
/personal/sbirkholz/meeting_registration@13954
|
||||||
|
|
|
@ -11,21 +11,28 @@ from ietf.community.models import CommunityList, SearchRule, EmailSubscription
|
||||||
from ietf.community.utils import docs_matching_community_list_rule, community_list_rules_matching_doc
|
from ietf.community.utils import docs_matching_community_list_rule, community_list_rules_matching_doc
|
||||||
from ietf.community.utils import reset_name_contains_index_for_rule
|
from ietf.community.utils import reset_name_contains_index_for_rule
|
||||||
import ietf.community.views
|
import ietf.community.views
|
||||||
|
from ietf.group.models import Group
|
||||||
from ietf.group.utils import setup_default_community_list_for_group
|
from ietf.group.utils import setup_default_community_list_for_group
|
||||||
from ietf.doc.models import State
|
from ietf.doc.models import State
|
||||||
from ietf.doc.utils import add_state_change_event
|
from ietf.doc.utils import add_state_change_event
|
||||||
from ietf.person.models import Person, Email
|
from ietf.person.models import Person, Email
|
||||||
from ietf.utils.test_data import make_test_data
|
|
||||||
from ietf.utils.test_utils import login_testing_unauthorized, TestCase, unicontent
|
from ietf.utils.test_utils import login_testing_unauthorized, TestCase, unicontent
|
||||||
from ietf.utils.mail import outbox
|
from ietf.utils.mail import outbox
|
||||||
from ietf.group.factories import GroupFactory
|
from ietf.doc.factories import WgDraftFactory
|
||||||
|
from ietf.group.factories import GroupFactory, RoleFactory
|
||||||
from ietf.person.factories import PersonFactory
|
from ietf.person.factories import PersonFactory
|
||||||
|
|
||||||
class CommunityListTests(TestCase):
|
class CommunityListTests(TestCase):
|
||||||
def test_rule_matching(self):
|
def test_rule_matching(self):
|
||||||
draft = make_test_data()
|
plain = PersonFactory(user__username='plain')
|
||||||
iesg_state = State.objects.get(type="draft-iesg", slug="lc")
|
ad = Person.objects.get(user__username='ad')
|
||||||
draft.set_state(iesg_state)
|
draft = WgDraftFactory(
|
||||||
|
group__parent=Group.objects.get(acronym='farfut' ),
|
||||||
|
authors=[ad],
|
||||||
|
ad=ad,
|
||||||
|
shepherd=plain.email(),
|
||||||
|
states=[('draft-iesg','lc'),('draft','active')],
|
||||||
|
)
|
||||||
|
|
||||||
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
|
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
|
||||||
|
|
||||||
|
@ -66,7 +73,8 @@ class CommunityListTests(TestCase):
|
||||||
self.assertTrue(draft in list(docs_matching_community_list_rule(rule_name_contains)))
|
self.assertTrue(draft in list(docs_matching_community_list_rule(rule_name_contains)))
|
||||||
|
|
||||||
def test_view_list(self):
|
def test_view_list(self):
|
||||||
draft = make_test_data()
|
PersonFactory(user__username='plain')
|
||||||
|
draft = WgDraftFactory()
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.view_list, kwargs={ "username": "plain" })
|
url = urlreverse(ietf.community.views.view_list, kwargs={ "username": "plain" })
|
||||||
|
|
||||||
|
@ -88,7 +96,9 @@ class CommunityListTests(TestCase):
|
||||||
self.assertTrue(draft.name in unicontent(r))
|
self.assertTrue(draft.name in unicontent(r))
|
||||||
|
|
||||||
def test_manage_personal_list(self):
|
def test_manage_personal_list(self):
|
||||||
draft = make_test_data()
|
PersonFactory(user__username='plain')
|
||||||
|
ad = Person.objects.get(user__username='ad')
|
||||||
|
draft = WgDraftFactory(authors=[ad])
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.manage_list, kwargs={ "username": "plain" })
|
url = urlreverse(ietf.community.views.manage_list, kwargs={ "username": "plain" })
|
||||||
login_testing_unauthorized(self, "plain", url)
|
login_testing_unauthorized(self, "plain", url)
|
||||||
|
@ -152,7 +162,8 @@ class CommunityListTests(TestCase):
|
||||||
self.assertTrue(not clist.searchrule_set.filter(rule_type="author_rfc"))
|
self.assertTrue(not clist.searchrule_set.filter(rule_type="author_rfc"))
|
||||||
|
|
||||||
def test_manage_group_list(self):
|
def test_manage_group_list(self):
|
||||||
draft = make_test_data()
|
draft = WgDraftFactory(group__acronym='mars')
|
||||||
|
RoleFactory(group__acronym='mars',name_id='chair',person=PersonFactory(user__username='marschairman'))
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.manage_list, kwargs={ "acronym": draft.group.acronym })
|
url = urlreverse(ietf.community.views.manage_list, kwargs={ "acronym": draft.group.acronym })
|
||||||
setup_default_community_list_for_group(draft.group)
|
setup_default_community_list_for_group(draft.group)
|
||||||
|
@ -176,7 +187,8 @@ class CommunityListTests(TestCase):
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
def test_track_untrack_document(self):
|
def test_track_untrack_document(self):
|
||||||
draft = make_test_data()
|
PersonFactory(user__username='plain')
|
||||||
|
draft = WgDraftFactory()
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.track_document, kwargs={ "username": "plain", "name": draft.name })
|
url = urlreverse(ietf.community.views.track_document, kwargs={ "username": "plain", "name": draft.name })
|
||||||
login_testing_unauthorized(self, "plain", url)
|
login_testing_unauthorized(self, "plain", url)
|
||||||
|
@ -201,7 +213,8 @@ class CommunityListTests(TestCase):
|
||||||
self.assertEqual(list(clist.added_docs.all()), [])
|
self.assertEqual(list(clist.added_docs.all()), [])
|
||||||
|
|
||||||
def test_track_untrack_document_through_ajax(self):
|
def test_track_untrack_document_through_ajax(self):
|
||||||
draft = make_test_data()
|
PersonFactory(user__username='plain')
|
||||||
|
draft = WgDraftFactory()
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.track_document, kwargs={ "username": "plain", "name": draft.name })
|
url = urlreverse(ietf.community.views.track_document, kwargs={ "username": "plain", "name": draft.name })
|
||||||
login_testing_unauthorized(self, "plain", url)
|
login_testing_unauthorized(self, "plain", url)
|
||||||
|
@ -222,7 +235,8 @@ class CommunityListTests(TestCase):
|
||||||
self.assertEqual(list(clist.added_docs.all()), [])
|
self.assertEqual(list(clist.added_docs.all()), [])
|
||||||
|
|
||||||
def test_csv(self):
|
def test_csv(self):
|
||||||
draft = make_test_data()
|
PersonFactory(user__username='plain')
|
||||||
|
draft = WgDraftFactory()
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.export_to_csv, kwargs={ "username": "plain" })
|
url = urlreverse(ietf.community.views.export_to_csv, kwargs={ "username": "plain" })
|
||||||
|
|
||||||
|
@ -245,7 +259,7 @@ class CommunityListTests(TestCase):
|
||||||
self.assertTrue(draft.name in unicontent(r))
|
self.assertTrue(draft.name in unicontent(r))
|
||||||
|
|
||||||
def test_csv_for_group(self):
|
def test_csv_for_group(self):
|
||||||
draft = make_test_data()
|
draft = WgDraftFactory()
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.export_to_csv, kwargs={ "acronym": draft.group.acronym })
|
url = urlreverse(ietf.community.views.export_to_csv, kwargs={ "acronym": draft.group.acronym })
|
||||||
|
|
||||||
|
@ -256,7 +270,8 @@ class CommunityListTests(TestCase):
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
def test_feed(self):
|
def test_feed(self):
|
||||||
draft = make_test_data()
|
PersonFactory(user__username='plain')
|
||||||
|
draft = WgDraftFactory()
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.feed, kwargs={ "username": "plain" })
|
url = urlreverse(ietf.community.views.feed, kwargs={ "username": "plain" })
|
||||||
|
|
||||||
|
@ -283,7 +298,7 @@ class CommunityListTests(TestCase):
|
||||||
self.assertTrue('<entry>' not in unicontent(r))
|
self.assertTrue('<entry>' not in unicontent(r))
|
||||||
|
|
||||||
def test_feed_for_group(self):
|
def test_feed_for_group(self):
|
||||||
draft = make_test_data()
|
draft = WgDraftFactory()
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.feed, kwargs={ "acronym": draft.group.acronym })
|
url = urlreverse(ietf.community.views.feed, kwargs={ "acronym": draft.group.acronym })
|
||||||
|
|
||||||
|
@ -294,7 +309,8 @@ class CommunityListTests(TestCase):
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
def test_subscription(self):
|
def test_subscription(self):
|
||||||
draft = make_test_data()
|
PersonFactory(user__username='plain')
|
||||||
|
draft = WgDraftFactory()
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.subscription, kwargs={ "username": "plain" })
|
url = urlreverse(ietf.community.views.subscription, kwargs={ "username": "plain" })
|
||||||
|
|
||||||
|
@ -331,7 +347,8 @@ class CommunityListTests(TestCase):
|
||||||
self.assertEqual(EmailSubscription.objects.filter(community_list=clist, email=email, notify_on="significant").count(), 0)
|
self.assertEqual(EmailSubscription.objects.filter(community_list=clist, email=email, notify_on="significant").count(), 0)
|
||||||
|
|
||||||
def test_subscription_for_group(self):
|
def test_subscription_for_group(self):
|
||||||
draft = make_test_data()
|
draft = WgDraftFactory(group__acronym='mars')
|
||||||
|
RoleFactory(group__acronym='mars',name_id='chair',person=PersonFactory(user__username='marschairman'))
|
||||||
|
|
||||||
url = urlreverse(ietf.community.views.subscription, kwargs={ "acronym": draft.group.acronym })
|
url = urlreverse(ietf.community.views.subscription, kwargs={ "acronym": draft.group.acronym })
|
||||||
|
|
||||||
|
@ -344,16 +361,11 @@ class CommunityListTests(TestCase):
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
def test_notification(self):
|
def test_notification(self):
|
||||||
draft = make_test_data()
|
PersonFactory(user__username='plain')
|
||||||
|
draft = WgDraftFactory()
|
||||||
|
|
||||||
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
|
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
|
||||||
clist.added_docs.add(draft)
|
clist.added_docs.add(draft)
|
||||||
SearchRule.objects.create(
|
|
||||||
community_list=clist,
|
|
||||||
rule_type="name_contains",
|
|
||||||
state=State.objects.get(type="draft", slug="active"),
|
|
||||||
text="test",
|
|
||||||
)
|
|
||||||
|
|
||||||
EmailSubscription.objects.create(community_list=clist, email=Email.objects.filter(person__user__username="plain").first(), notify_on="significant")
|
EmailSubscription.objects.create(community_list=clist, email=Email.objects.filter(person__user__username="plain").first(), notify_on="significant")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue