99import debug # pyflakes:ignore
1010
1111from ietf .doc .factories import WgDraftFactory , WgRfcFactory
12- from ietf .doc .models import Document , DocAlias , RelatedDocument , State
12+ from ietf .doc .models import RelatedDocument , State
1313from ietf .person .factories import PersonFactory
1414from ietf .utils .test_utils import TestCase
1515from ietf .utils .test_utils import login_testing_unauthorized , unicontent
@@ -18,10 +18,13 @@ class Downref(TestCase):
1818
1919 def setUp (self ):
2020 PersonFactory (name = 'Plain Man' ,user__username = 'plain' )
21- WgDraftFactory (name = 'draft-ietf-mars-test' )
22- doc = WgDraftFactory (name = 'draft-ietf-mars-approved-document' ,states = [('draft-iesg' ,'rfcqueue' )])
23- rfc = WgRfcFactory (alias2__name = 'rfc9998' )
24- RelatedDocument .objects .create (source = doc , target = rfc .docalias .get (name = 'rfc9998' ),relationship_id = 'downref-approval' )
21+ self .draft = WgDraftFactory (name = 'draft-ietf-mars-test' )
22+ self .draftalias = self .draft .docalias .get (name = 'draft-ietf-mars-test' )
23+ self .doc = WgDraftFactory (name = 'draft-ietf-mars-approved-document' ,states = [('draft-iesg' ,'rfcqueue' )])
24+ self .docalias = self .doc .docalias .get (name = 'draft-ietf-mars-approved-document' )
25+ self .rfc = WgRfcFactory (alias2__name = 'rfc9998' )
26+ self .rfcalias = self .rfc .docalias .get (name = 'rfc9998' )
27+ RelatedDocument .objects .create (source = self .doc , target = self .rfcalias , relationship_id = 'downref-approval' )
2528
2629 def test_downref_registry (self ):
2730 url = urlreverse ('ietf.doc.views_downref.downref_registry' )
@@ -71,48 +74,46 @@ def test_downref_registry_add(self):
7174 self .assertTrue ('Save downref' in content )
7275
7376 # error - already in the downref registry
74- r = self .client .post (url , dict (rfc = 'rfc9998' , drafts = ('draft-ietf-mars-approved-document' , )))
77+ r = self .client .post (url , dict (rfc = self . rfcalias . pk , drafts = (self . doc . pk , )))
7578 self .assertEqual (r .status_code , 200 )
7679 content = unicontent (r )
7780 self .assertTrue ('Downref is already in the registry' in content )
7881
7982 # error - source is not in an approved state
8083 r = self .client .get (url )
8184 self .assertEqual (r .status_code , 200 )
82- r = self .client .post (url , dict (rfc = 'rfc9998' , drafts = (' draft-ietf-mars-test' , )))
85+ r = self .client .post (url , dict (rfc = self . rfcalias . pk , drafts = (self . draft . pk , )))
8386 self .assertEqual (r .status_code , 200 )
8487 content = unicontent (r )
8588 self .assertTrue ('Draft is not yet approved' in content )
8689
8790 # error - the target is not a normative reference of the source
88- draft = Document .objects .get (name = "draft-ietf-mars-test" )
89- draft .set_state (State .objects .get (used = True , type = "draft-iesg" , slug = "pub" ))
91+ self .draft .set_state (State .objects .get (used = True , type = "draft-iesg" , slug = "pub" ))
9092 r = self .client .get (url )
9193 self .assertEqual (r .status_code , 200 )
92- r = self .client .post (url , dict (rfc = 'rfc9998' , drafts = (' draft-ietf-mars-test' , )))
94+ r = self .client .post (url , dict (rfc = self . rfcalias . pk , drafts = (self . draft . pk , )))
9395 self .assertEqual (r .status_code , 200 )
9496 content = unicontent (r )
9597 self .assertTrue ('There does not seem to be a normative reference to RFC' in content )
9698 self .assertTrue ('Save downref anyway' in content )
9799
98100 # normal - approve the document so the downref is now okay
99- rfc = DocAlias .objects .get (name = "rfc9998" )
100- RelatedDocument .objects .create (source = draft , target = rfc , relationship_id = 'refnorm' )
101- draft_de_count_before = draft .docevent_set .count ()
102- rfc_de_count_before = rfc .document .docevent_set .count ()
101+ RelatedDocument .objects .create (source = self .draft , target = self .rfcalias , relationship_id = 'refnorm' )
102+ draft_de_count_before = self .draft .docevent_set .count ()
103+ rfc_de_count_before = self .rfc .docevent_set .count ()
103104
104105 r = self .client .get (url )
105106 self .assertEqual (r .status_code , 200 )
106- r = self .client .post (url , dict (rfc = 'rfc9998' , drafts = (' draft-ietf-mars-test' , )))
107+ r = self .client .post (url , dict (rfc = self . rfcalias . pk , drafts = (self . draft . pk , )))
107108 self .assertEqual (r .status_code , 302 )
108109 newurl = urlreverse ('ietf.doc.views_downref.downref_registry' )
109110 r = self .client .get (newurl )
110111 self .assertEqual (r .status_code , 200 )
111112 content = unicontent (r )
112113 self .assertTrue ('<a href="/doc/draft-ietf-mars-test' in content )
113- self .assertTrue (RelatedDocument .objects .filter (source = draft , target = rfc , relationship_id = 'downref-approval' ))
114- self .assertEqual (draft .docevent_set .count (), draft_de_count_before + 1 )
115- self .assertEqual (rfc . document .docevent_set .count (), rfc_de_count_before + 1 )
114+ self .assertTrue (RelatedDocument .objects .filter (source = self . draft , target = self . rfcalias , relationship_id = 'downref-approval' ))
115+ self .assertEqual (self . draft .docevent_set .count (), draft_de_count_before + 1 )
116+ self .assertEqual (self . rfc .docevent_set .count (), rfc_de_count_before + 1 )
116117
117118 def test_downref_last_call (self ):
118119 draft = WgDraftFactory (name = 'draft-ietf-mars-ready-for-lc-document' ,intended_std_level_id = 'ps' ,states = [('draft-iesg' ,'iesg-eva' )])
0 commit comments