Skip to content

Commit d0832e2

Browse files
committed
Merged in [15205] from rjsparks@nostrum.com:
more factoryization of ietf.doc.tests. - Legacy-Id: 15221 Note: SVN reference [15205] has been migrated to Git commit 84d3c92
2 parents ab53e80 + 84d3c92 commit d0832e2

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

ietf/doc/factories.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class DocumentFactory(BaseDocumentFactory):
6363
# TODO : If more than one document is created in a test with this factory,
6464
# and group isn't explicitly specified, this will violate the assumption
6565
# that there is only one group of type 'individ'
66-
group = factory.SubFactory('ietf.group.factories.GroupFactory',type_id='individ')
66+
# Update : this, along with the django_get_or_create in GroupFactory is better, but replace this with traits and a post_generation hoook.
67+
group = factory.SubFactory('ietf.group.factories.GroupFactory',type_id='individ',acronym='none')
6768

6869
class CharterFactory(BaseDocumentFactory):
6970

ietf/doc/tests.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from ietf.group.factories import GroupFactory
2929
from ietf.meeting.models import Meeting, Session, SessionPresentation
3030
from ietf.meeting.factories import MeetingFactory, SessionFactory
31-
from ietf.meeting.test_data import make_meeting_test_data
31+
#from ietf.meeting.test_data import make_meeting_test_data
3232
from ietf.name.models import SessionStatusName
3333
from ietf.person.models import Person
3434
from ietf.person.factories import PersonFactory
@@ -610,8 +610,16 @@ def test_document_draft(self):
610610
self.assertEqual(r.status_code, 404)
611611

612612
def test_document_primary_and_history_views(self):
613-
make_test_data()
614-
make_meeting_test_data()
613+
#make_test_data()
614+
#make_meeting_test_data()
615+
DocumentFactory(name='draft-imaginary-independent-submission')
616+
ConflictReviewFactory(name='conflict-review-imaginary-irtf-submission')
617+
CharterFactory(name='charter-ietf-mars')
618+
DocumentFactory(type_id='agenda',name='agenda-42-mars')
619+
DocumentFactory(type_id='minutes',name='minutes-42-mars')
620+
DocumentFactory(type_id='slides',name='slides-42-mars-1-active')
621+
statchg = DocumentFactory(type_id='statchg',name='status-change-imaginary-mid-review')
622+
statchg.set_state(State.objects.get(type_id='statchg',slug='adrev'))
615623

616624
# Ensure primary views of both current and historic versions of documents works
617625
for docname in ["draft-imaginary-independent-submission",
@@ -684,7 +692,7 @@ def test_document_material(self):
684692
self.assertEqual(r.status_code, 200)
685693

686694
def test_document_ballot(self):
687-
doc = make_test_data()
695+
doc = DocumentFactory()
688696
ad = Person.objects.get(user__username="ad")
689697
ballot = create_ballot_if_not_open(None, doc, ad, 'approve')
690698
assert ballot == doc.active_ballot()
@@ -728,7 +736,9 @@ def test_document_ballot(self):
728736

729737
def test_document_ballot_needed_positions(self):
730738
# draft
731-
doc = make_test_data()
739+
doc = DocumentFactory(intended_std_level_id='ps')
740+
doc.set_state(State.objects.get(type_id='draft-iesg',slug='iesg-eva'))
741+
doc.set_state(State.objects.get(type_id='draft',slug='active'))
732742
ad = Person.objects.get(user__username="ad")
733743
create_ballot_if_not_open(None, doc, ad, 'approve')
734744

@@ -739,7 +749,9 @@ def test_document_ballot_needed_positions(self):
739749
self.assertFalse('more YES or NO' in unicontent(r))
740750

741751
# status change
742-
doc = Document.objects.get(name='status-change-imaginary-mid-review')
752+
DocumentFactory().docalias_set.create(name='rfc9998')
753+
DocumentFactory().docalias_set.create(name='rfc9999')
754+
doc = DocumentFactory(type_id='statchg',name='status-change-imaginary-mid-review')
743755
iesgeval_pk = str(State.objects.get(slug='iesgeval',type__slug='statchg').pk)
744756
self.client.login(username='ad', password='ad+password')
745757
r = self.client.post(urlreverse('ietf.doc.views_status_change.change_state',kwargs=dict(name=doc.name)),dict(new_state=iesgeval_pk))

ietf/doc/tests_charter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import debug # pyflakes:ignore
1212

13-
from ietf.doc.factories import DocumentFactory, CharterFactory
13+
from ietf.doc.factories import CharterFactory
1414
from ietf.doc.models import ( Document, State, BallotDocEvent, BallotType, NewRevisionDocEvent,
1515
TelechatDocEvent, WriteupDocEvent )
1616
from ietf.doc.utils_charter import ( next_revision, default_review_text, default_action_text,
@@ -697,6 +697,6 @@ def test_charter_with_milestones(self):
697697

698698
def test_chartering_from_bof(self):
699699
ad_role = RoleFactory(group__type_id='area',name_id='ad')
700-
charter = DocumentFactory(type_id='charter',group__type_id='wg',group__state_id='bof',group__parent=ad_role.group)
700+
charter = CharterFactory(group__type_id='wg',group__state_id='bof',group__parent=ad_role.group)
701701
e1,_ = default_review_text(charter.group, charter, Person.objects.get(name="(System)"))
702702
self.assertTrue('A new IETF WG has been proposed' in e1.text)

ietf/group/factories.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
class GroupFactory(factory.DjangoModelFactory):
88
class Meta:
99
model = Group
10+
django_get_or_create = ('acronym',)
1011

1112
name = factory.Faker('sentence',nb_words=6)
1213
acronym = factory.Sequence(lambda n: 'acronym%d' %n)

0 commit comments

Comments
 (0)