Skip to content

Commit

Permalink
more factoryization of ietf.doc.tests. Commit ready for merge.
Browse files Browse the repository at this point in the history
 - Legacy-Id: 15205
  • Loading branch information
rjsparks committed Jun 2, 2018
1 parent 4e7743c commit 84d3c92
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
3 changes: 2 additions & 1 deletion ietf/doc/factories.py
Expand Up @@ -63,7 +63,8 @@ class DocumentFactory(BaseDocumentFactory):
# TODO : If more than one document is created in a test with this factory,
# and group isn't explicitly specified, this will violate the assumption
# that there is only one group of type 'individ'
group = factory.SubFactory('ietf.group.factories.GroupFactory',type_id='individ')
# Update : this, along with the django_get_or_create in GroupFactory is better, but replace this with traits and a post_generation hoook.
group = factory.SubFactory('ietf.group.factories.GroupFactory',type_id='individ',acronym='none')

class CharterFactory(BaseDocumentFactory):

Expand Down
24 changes: 18 additions & 6 deletions ietf/doc/tests.py
Expand Up @@ -28,7 +28,7 @@
from ietf.group.factories import GroupFactory
from ietf.meeting.models import Meeting, Session, SessionPresentation
from ietf.meeting.factories import MeetingFactory, SessionFactory
from ietf.meeting.test_data import make_meeting_test_data
#from ietf.meeting.test_data import make_meeting_test_data
from ietf.name.models import SessionStatusName
from ietf.person.models import Person
from ietf.person.factories import PersonFactory
Expand Down Expand Up @@ -610,8 +610,16 @@ def test_document_draft(self):
self.assertEqual(r.status_code, 404)

def test_document_primary_and_history_views(self):
make_test_data()
make_meeting_test_data()
#make_test_data()
#make_meeting_test_data()
DocumentFactory(name='draft-imaginary-independent-submission')
ConflictReviewFactory(name='conflict-review-imaginary-irtf-submission')
CharterFactory(name='charter-ietf-mars')
DocumentFactory(type_id='agenda',name='agenda-42-mars')
DocumentFactory(type_id='minutes',name='minutes-42-mars')
DocumentFactory(type_id='slides',name='slides-42-mars-1-active')
statchg = DocumentFactory(type_id='statchg',name='status-change-imaginary-mid-review')
statchg.set_state(State.objects.get(type_id='statchg',slug='adrev'))

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

def test_document_ballot(self):
doc = make_test_data()
doc = DocumentFactory()
ad = Person.objects.get(user__username="ad")
ballot = create_ballot_if_not_open(None, doc, ad, 'approve')
assert ballot == doc.active_ballot()
Expand Down Expand Up @@ -728,7 +736,9 @@ def test_document_ballot(self):

def test_document_ballot_needed_positions(self):
# draft
doc = make_test_data()
doc = DocumentFactory(intended_std_level_id='ps')
doc.set_state(State.objects.get(type_id='draft-iesg',slug='iesg-eva'))
doc.set_state(State.objects.get(type_id='draft',slug='active'))
ad = Person.objects.get(user__username="ad")
create_ballot_if_not_open(None, doc, ad, 'approve')

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

# status change
doc = Document.objects.get(name='status-change-imaginary-mid-review')
DocumentFactory().docalias_set.create(name='rfc9998')
DocumentFactory().docalias_set.create(name='rfc9999')
doc = DocumentFactory(type_id='statchg',name='status-change-imaginary-mid-review')
iesgeval_pk = str(State.objects.get(slug='iesgeval',type__slug='statchg').pk)
self.client.login(username='ad', password='ad+password')
r = self.client.post(urlreverse('ietf.doc.views_status_change.change_state',kwargs=dict(name=doc.name)),dict(new_state=iesgeval_pk))
Expand Down
4 changes: 2 additions & 2 deletions ietf/doc/tests_charter.py
Expand Up @@ -10,7 +10,7 @@

import debug # pyflakes:ignore

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

def test_chartering_from_bof(self):
ad_role = RoleFactory(group__type_id='area',name_id='ad')
charter = DocumentFactory(type_id='charter',group__type_id='wg',group__state_id='bof',group__parent=ad_role.group)
charter = CharterFactory(group__type_id='wg',group__state_id='bof',group__parent=ad_role.group)
e1,_ = default_review_text(charter.group, charter, Person.objects.get(name="(System)"))
self.assertTrue('A new IETF WG has been proposed' in e1.text)
1 change: 1 addition & 0 deletions ietf/group/factories.py
Expand Up @@ -7,6 +7,7 @@
class GroupFactory(factory.DjangoModelFactory):
class Meta:
model = Group
django_get_or_create = ('acronym',)

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

0 comments on commit 84d3c92

Please sign in to comment.