1313import debug # pyflakes:ignore
1414
1515from django .urls import reverse as urlreverse
16- from django .utils import timezone
1716
1817from ietf .utils .test_utils import login_testing_unauthorized , TestCase
1918import ietf .stats .views
2019
21- from ietf .submit .models import Submission
22- from ietf .doc .factories import WgDraftFactory , WgRfcFactory
23- from ietf .doc .models import Document , State , RelatedDocument , NewRevisionDocEvent , DocumentAuthor
20+
2421from ietf .group .factories import RoleFactory
25- from ietf .meeting .factories import MeetingFactory , AttendedFactory
22+ from ietf .meeting .factories import MeetingFactory
2623from ietf .person .factories import PersonFactory
27- from ietf .person .models import Person , Email
28- from ietf .name .models import FormalLanguageName , DocRelationshipName , CountryName
2924from ietf .review .factories import ReviewRequestFactory , ReviewerSettingsFactory , ReviewAssignmentFactory
30- from ietf .stats .models import MeetingRegistration , CountryAlias
31- from ietf .stats .factories import MeetingRegistrationFactory
25+ from ietf .stats .models import MeetingRegistration
3226from ietf .stats .tasks import fetch_meeting_attendance_task
3327from ietf .stats .utils import get_meeting_registration_data , FetchStats , fetch_attendance_from_meetings
3428from ietf .utils .timezone import date_today
@@ -41,121 +35,14 @@ def test_stats_index(self):
4135 self .assertEqual (r .status_code , 200 )
4236
4337 def test_document_stats (self ):
44- WgRfcFactory ()
45- draft = WgDraftFactory ()
46- DocumentAuthor .objects .create (
47- document = draft ,
48- person = Person .objects .get (email__address = "aread@example.org" ),
49- email = Email .objects .get (address = "aread@example.org" ),
50- country = "Germany" ,
51- affiliation = "IETF" ,
52- order = 1
53- )
54-
55- # create some data for the statistics
56- Submission .objects .create (
57- authors = [ { "name" : "Some Body" , "email" : "somebody@example.com" , "affiliation" : "Some Inc." , "country" : "US" }],
58- pages = 30 ,
59- rev = draft .rev ,
60- words = 4000 ,
61- draft = draft ,
62- file_types = ".txt" ,
63- state_id = "posted" ,
64- )
65-
66- draft .formal_languages .add (FormalLanguageName .objects .get (slug = "xml" ))
67- Document .objects .filter (pk = draft .pk ).update (words = 4000 )
68- # move it back so it shows up in the yearly summaries
69- NewRevisionDocEvent .objects .filter (doc = draft , rev = draft .rev ).update (
70- time = timezone .now () - datetime .timedelta (days = 500 ))
71-
72- referencing_draft = Document .objects .create (
73- name = "draft-ietf-mars-referencing" ,
74- type_id = "draft" ,
75- title = "Referencing" ,
76- stream_id = "ietf" ,
77- abstract = "Test" ,
78- rev = "00" ,
79- pages = 2 ,
80- words = 100
81- )
82- referencing_draft .set_state (State .objects .get (used = True , type = "draft" , slug = "active" ))
83- RelatedDocument .objects .create (
84- source = referencing_draft ,
85- target = draft ,
86- relationship = DocRelationshipName .objects .get (slug = "refinfo" )
87- )
88- NewRevisionDocEvent .objects .create (
89- type = "new_revision" ,
90- by = Person .objects .get (name = "(System)" ),
91- doc = referencing_draft ,
92- desc = "New revision available" ,
93- rev = referencing_draft .rev ,
94- time = timezone .now () - datetime .timedelta (days = 1000 )
95- )
38+ r = self .client .get (urlreverse ("ietf.stats.views.document_stats" ))
39+ self .assertRedirects (r , urlreverse ("ietf.stats.views.stats_index" ))
9640
9741
98- # check redirect
99- url = urlreverse (ietf .stats .views .document_stats )
100-
101- authors_url = urlreverse (ietf .stats .views .document_stats , kwargs = { "stats_type" : "authors" })
102-
103- r = self .client .get (url )
104- self .assertEqual (r .status_code , 302 )
105- self .assertTrue (authors_url in r ["Location" ])
106-
107- # check various stats types
108- for stats_type in ["authors" , "pages" , "words" , "format" , "formlang" ,
109- "author/documents" , "author/affiliation" , "author/country" ,
110- "author/continent" , "author/citations" , "author/hindex" ,
111- "yearly/affiliation" , "yearly/country" , "yearly/continent" ]:
112- for document_type in ["" , "rfc" , "draft" ]:
113- for time_choice in ["" , "5y" ]:
114- url = urlreverse (ietf .stats .views .document_stats , kwargs = { "stats_type" : stats_type })
115- r = self .client .get (url , {
116- "type" : document_type ,
117- "time" : time_choice ,
118- })
119- self .assertEqual (r .status_code , 200 )
120- q = PyQuery (r .content )
121- self .assertTrue (q ('#chart' ))
122- if not stats_type .startswith ("yearly" ):
123- self .assertTrue (q ('table.stats-data' ))
124-
12542 def test_meeting_stats (self ):
126- # create some data for the statistics
127- meeting = MeetingFactory (type_id = 'ietf' , date = date_today (), number = "96" )
128- MeetingRegistrationFactory (first_name = 'John' , last_name = 'Smith' , country_code = 'US' , email = "john.smith@example.us" , meeting = meeting , attended = True )
129- CountryAlias .objects .get_or_create (alias = "US" , country = CountryName .objects .get (slug = "US" ))
130- p = MeetingRegistrationFactory (first_name = 'Jaume' , last_name = 'Guillaume' , country_code = 'FR' , email = "jaume.guillaume@example.fr" , meeting = meeting , attended = False ).person
131- CountryAlias .objects .get_or_create (alias = "FR" , country = CountryName .objects .get (slug = "FR" ))
132- AttendedFactory (session__meeting = meeting ,person = p )
133- # check redirect
134- url = urlreverse (ietf .stats .views .meeting_stats )
135-
136- authors_url = urlreverse (ietf .stats .views .meeting_stats , kwargs = { "stats_type" : "overview" })
137-
138- r = self .client .get (url )
139- self .assertEqual (r .status_code , 302 )
140- self .assertTrue (authors_url in r ["Location" ])
141-
142- # check various stats types
143- for stats_type in ["overview" , "country" , "continent" ]:
144- url = urlreverse (ietf .stats .views .meeting_stats , kwargs = { "stats_type" : stats_type })
145- r = self .client .get (url )
146- self .assertEqual (r .status_code , 200 )
147- q = PyQuery (r .content )
148- self .assertTrue (q ('#chart' ))
149- if stats_type == "overview" :
150- self .assertTrue (q ('table.stats-data' ))
43+ r = self .client .get (urlreverse ("ietf.stats.views.meeting_stats" ))
44+ self .assertRedirects (r , urlreverse ("ietf.stats.views.stats_index" ))
15145
152- for stats_type in ["country" , "continent" ]:
153- url = urlreverse (ietf .stats .views .meeting_stats , kwargs = { "stats_type" : stats_type , "num" : meeting .number })
154- r = self .client .get (url )
155- self .assertEqual (r .status_code , 200 )
156- q = PyQuery (r .content )
157- self .assertTrue (q ('#chart' ))
158- self .assertTrue (q ('table.stats-data' ))
15946
16047 def test_known_country_list (self ):
16148 # check redirect
0 commit comments