1919import debug # pyflakes:ignore
2020
2121from ietf .submit .utils import expirable_submissions , expire_submission , ensure_person_email_info_exists
22+ from ietf .doc .factories import DocumentFactory , WgDraftFactory , IndividualDraftFactory
2223from ietf .doc .models import Document , DocAlias , DocEvent , State , BallotPositionDocEvent , DocumentAuthor
2324from ietf .doc .utils import create_ballot_if_not_open
25+ from ietf .group .factories import GroupFactory , RoleFactory
2426from ietf .group .models import Group
2527from ietf .group .utils import setup_default_community_list_for_group
2628from ietf .meeting .models import Meeting
3335from ietf .submit .mail import add_submission_email , process_response_email
3436from ietf .utils .mail import outbox , empty_outbox
3537from ietf .utils .models import VersionInfo
36- from ietf .utils .test_data import make_test_data
3738from ietf .utils .test_utils import login_testing_unauthorized , unicontent , TestCase
3839from ietf .utils .draft import Draft
3940
@@ -97,6 +98,9 @@ def setUp(self):
9798 self .yang_iana_model_dir = self .tempdir ('yang-iana-model' )
9899 settings .SUBMIT_YANG_IANA_MODEL_DIR = self .yang_iana_model_dir
99100
101+ # Submit views assume there is a "next" IETF to look for cutoff dates against
102+ MeetingFactory (type_id = 'ietf' , date = datetime .date .today ()+ datetime .timedelta (days = 180 ))
103+
100104 def tearDown (self ):
101105 shutil .rmtree (self .staging_dir )
102106 shutil .rmtree (self .repository_dir )
@@ -195,7 +199,10 @@ def extract_confirm_url(self, confirm_email):
195199
196200 def submit_new_wg (self , formats ):
197201 # submit new -> supply submitter info -> approve
198- draft = make_test_data ()
202+ GroupFactory (type_id = 'wg' ,acronym = 'ames' )
203+ mars = GroupFactory (type_id = 'wg' , acronym = 'mars' )
204+ RoleFactory (name_id = 'chair' , group = mars , person__user__username = 'marschairman' )
205+ draft = WgDraftFactory (group = mars )
199206 setup_default_community_list_for_group (draft .group )
200207
201208 # prepare draft to suggest replace
@@ -314,13 +321,19 @@ def text_submit_new_wg_txt_xml(self):
314321
315322 def submit_existing (self , formats , change_authors = True , group_type = 'wg' , stream_type = 'ietf' ):
316323 # submit new revision of existing -> supply submitter info -> prev authors confirm
317- draft = make_test_data ()
318- if not group_type == 'wg' :
319- draft .group .type_id = group_type
320- draft .group .save ()
321- if not stream_type == 'ietf' :
322- draft .stream_id = stream_type
323- draft .save_with_history ([DocEvent .objects .create (doc = draft , rev = draft .rev , type = "added_comment" , by = Person .objects .get (user__username = "secretary" ), desc = "Test" )])
324+ # The tests expect the draft to always have an ad, but that doesn't match what happens for most streams
325+ ad = Person .objects .get (user__username = 'ad' )
326+ if group_type == 'area' :
327+ group = GroupFactory (type_id = 'area' , acronym = 'mars' )
328+ RoleFactory (name_id = 'ad' , group = group , person = ad )
329+ else :
330+ area = GroupFactory (type_id = 'area' )
331+ RoleFactory (name_id = 'ad' ,group = area ,person = ad )
332+ group = GroupFactory (type_id = group_type , parent = area , acronym = 'mars' )
333+ draft = DocumentFactory (type_id = 'draft' , group = group , stream_id = stream_type , ad = ad , authors = PersonFactory .create_batch (1 ))
334+ if stream_type == 'ietf' :
335+ draft .set_state (State .objects .get (type_id = 'draft-stream-ietf' ,slug = 'wg-doc' ))
336+
324337 prev_author = draft .documentauthor_set .all ()[0 ]
325338 if change_authors :
326339 # Make it such that one of the previous authors has an invalid email address
@@ -503,7 +516,6 @@ def test_submit_existing_ise(self):
503516
504517 def submit_new_individual (self , formats ):
505518 # submit new -> supply submitter info -> confirm
506- draft = make_test_data ()
507519
508520 name = "draft-authorname-testing-tests"
509521 rev = "00"
@@ -558,9 +570,10 @@ def test_submit_new_individual_txt_xml(self):
558570 self .submit_new_individual (["txt" , "xml" ])
559571
560572 def test_submit_update_individual (self ):
561- draft = make_test_data ()
562- draft .group = None
563- draft .save_with_history ([DocEvent .objects .create (doc = draft , rev = draft .rev , type = "added_comment" , by = Person .objects .get (user__username = "secretary" ), desc = "Test" )])
573+ IndividualDraftFactory (name = 'draft-ietf-random-thing' , states = [('draft' ,'rfc' )], other_aliases = ['rfc9999' ,], pages = 5 )
574+ ad = Person .objects .get (user__username = 'ad' )
575+ # Group of None here does not reflect real individual submissions
576+ draft = IndividualDraftFactory (group = None , ad = ad , authors = [ad ,], notify = 'aliens@example.mars' , pages = 5 )
564577 replaces_count = draft .relateddocument_set .filter (relationship_id = 'replaces' ).count ()
565578 name = draft .name
566579 rev = '%02d' % (int (draft .rev )+ 1 )
@@ -600,9 +613,9 @@ def test_submit_update_individual(self):
600613 self .assertIn (draft .title , unicontent (r ))
601614
602615 def test_submit_cancel_confirmation (self ):
603- draft = make_test_data ( )
604- draft . group = None
605- draft . save_with_history ([ DocEvent . objects . create ( doc = draft , rev = draft . rev , type = "added_comment" , by = Person . objects . get ( user__username = "secretary" ), desc = "Test" )] )
616+ ad = Person . objects . get ( user__username = 'ad' )
617+ # Group of None here does not reflect real individual submissions
618+ draft = IndividualDraftFactory ( group = None , ad = ad , authors = [ ad ,], notify = 'aliens@example.mars' , pages = 5 )
606619 name = draft .name
607620 old_rev = draft .rev
608621 rev = '%02d' % (int (draft .rev )+ 1 )
@@ -622,8 +635,6 @@ def test_submit_cancel_confirmation(self):
622635 self .assertEqual (draft .rev , old_rev )
623636
624637 def test_submit_new_wg_with_dash (self ):
625- make_test_data ()
626-
627638 group = Group .objects .create (acronym = "mars-special" , name = "Mars Special" , type_id = "wg" , state_id = "active" )
628639
629640 name = "draft-ietf-%s-testing-tests" % group .acronym
@@ -633,8 +644,6 @@ def test_submit_new_wg_with_dash(self):
633644 self .assertEqual (Submission .objects .get (name = name ).group .acronym , group .acronym )
634645
635646 def test_submit_new_irtf (self ):
636- make_test_data ()
637-
638647 group = Group .objects .create (acronym = "saturnrg" , name = "Saturn" , type_id = "rg" , state_id = "active" )
639648
640649 name = "draft-irtf-%s-testing-tests" % group .acronym
@@ -645,8 +654,6 @@ def test_submit_new_irtf(self):
645654 self .assertEqual (Submission .objects .get (name = name ).group .type_id , group .type_id )
646655
647656 def test_submit_new_iab (self ):
648- make_test_data ()
649-
650657 name = "draft-iab-testing-tests"
651658
652659 self .do_submission (name , "00" )
@@ -655,7 +662,7 @@ def test_submit_new_iab(self):
655662
656663 def test_cancel_submission (self ):
657664 # submit -> cancel
658- make_test_data ( )
665+ GroupFactory ( acronym = 'mars' )
659666
660667 name = "draft-ietf-mars-testing-tests"
661668 rev = "00"
@@ -677,7 +684,7 @@ def test_cancel_submission(self):
677684
678685 def test_edit_submission_and_force_post (self ):
679686 # submit -> edit
680- draft = make_test_data ( )
687+ draft = WgDraftFactory ( group__acronym = 'mars' )
681688
682689 name = "draft-ietf-mars-testing-tests"
683690 rev = "00"
@@ -773,7 +780,7 @@ def test_edit_submission_and_force_post(self):
773780
774781 def test_search_for_submission_and_edit_as_secretariat (self ):
775782 # submit -> edit
776- make_test_data ( )
783+ GroupFactory ( acronym = 'mars' )
777784
778785 name = "draft-ietf-mars-testing-tests"
779786 rev = "00"
@@ -823,7 +830,7 @@ def test_search_for_submission_and_edit_as_secretariat(self):
823830
824831 def test_request_full_url (self ):
825832 # submit -> request full URL to be sent
826- make_test_data ( )
833+ GroupFactory ( acronym = 'mars' )
827834
828835 name = "draft-ietf-mars-testing-tests"
829836 rev = "00"
@@ -855,8 +862,7 @@ def test_request_full_url(self):
855862 # who gets the management url behaves as expected
856863
857864 def test_submit_all_file_types (self ):
858- make_test_data ()
859-
865+ GroupFactory (acronym = 'mars' )
860866 name = "draft-ietf-mars-testing-tests"
861867 rev = "00"
862868 group = "mars"
@@ -910,14 +916,12 @@ def test_help_pages(self):
910916 self .assertEquals (r .status_code , 200 )
911917
912918 def test_blackout_access (self ):
913- make_test_data ()
914-
915919 # get
916920 url = urlreverse ('ietf.submit.views.upload_submission' )
917- # set meeting to today so we're in blackout period
921+
922+ # Put today in the blackout period
918923 meeting = Meeting .get_current_meeting ()
919- meeting .date = datetime .datetime .utcnow ()
920- meeting .save ()
924+ meeting .importantdate_set .create (name_id = 'idcutoff' ,date = datetime .date .today ()- datetime .timedelta (days = 2 ))
921925
922926 # regular user, no access
923927 r = self .client .get (url )
@@ -933,9 +937,6 @@ def test_blackout_access(self):
933937 self .assertEqual (len (q ('input[type=file][name=txt]' )), 1 )
934938
935939 def submit_bad_file (self , name , formats ):
936-
937- make_test_data ()
938-
939940 rev = ""
940941 group = None
941942
@@ -988,8 +989,6 @@ def test_submit_bad_file_ps(self):
988989 self .assertIn ('Expected an PS file of type "application/postscript"' , m )
989990
990991 def test_submit_nonascii_name (self ):
991- make_test_data ()
992-
993992 name = "draft-authorname-testing-nonascii"
994993 rev = "00"
995994 group = None
@@ -1018,8 +1017,6 @@ def test_submit_nonascii_name(self):
10181017 self .assertIn ('The idnits check returned 1 warning' , m )
10191018
10201019 def test_submit_invalid_yang (self ):
1021- make_test_data ()
1022-
10231020 name = "draft-yang-testing-invalid"
10241021 rev = "00"
10251022 group = None
@@ -1054,8 +1051,7 @@ def test_submit_invalid_yang(self):
10541051
10551052class ApprovalsTestCase (TestCase ):
10561053 def test_approvals (self ):
1057- make_test_data ()
1058-
1054+ RoleFactory (name_id = 'chair' , group__acronym = 'mars' , person__user__username = 'marschairman' )
10591055 url = urlreverse ('ietf.submit.views.approvals' )
10601056 self .client .login (username = "marschairman" , password = "marschairman+password" )
10611057
@@ -1085,7 +1081,7 @@ def test_approvals(self):
10851081 self .assertEqual (len (q ('.recently-approved a:contains("draft-ietf-mars-foo")' )), 1 )
10861082
10871083 def test_add_preapproval (self ):
1088- make_test_data ( )
1084+ RoleFactory ( name_id = 'chair' , group__acronym = 'mars' , person__user__username = 'marschairman' )
10891085
10901086 url = urlreverse ('ietf.submit.views.add_preapproval' )
10911087 login_testing_unauthorized (self , "marschairman" , url )
@@ -1110,7 +1106,7 @@ def test_add_preapproval(self):
11101106 self .assertEqual (len (Preapproval .objects .filter (name = name )), 1 )
11111107
11121108 def test_cancel_preapproval (self ):
1113- make_test_data ( )
1109+ RoleFactory ( name_id = 'chair' , group__acronym = 'mars' , person__user__username = 'marschairman' )
11141110
11151111 preapproval = Preapproval .objects .create (name = "draft-ietf-mars-foo" , by = Person .objects .get (user__username = "marschairman" ))
11161112
@@ -1131,7 +1127,7 @@ def test_cancel_preapproval(self):
11311127
11321128class ManualPostsTestCase (TestCase ):
11331129 def test_manual_posts (self ):
1134- make_test_data ( )
1130+ GroupFactory ( acronym = 'mars' )
11351131
11361132 url = urlreverse ('ietf.submit.views.manualpost' )
11371133 # Secretariat has access
0 commit comments