|
8 | 8 |
|
9 | 9 | from ietf.utils.test_data import make_test_data, make_review_data |
10 | 10 | from ietf.utils.test_utils import login_testing_unauthorized, TestCase, unicontent |
11 | | -from ietf.stats.models import MeetingRegistration |
12 | | -from ietf.stats.utils import get_meeting_registration_data |
13 | 11 | import ietf.stats.views |
14 | 12 |
|
15 | 13 | from ietf.submit.models import Submission |
16 | 14 | from ietf.doc.models import Document, DocAlias, State, RelatedDocument, NewRevisionDocEvent |
17 | 15 | from ietf.meeting.factories import MeetingFactory |
18 | 16 | from ietf.person.models import Person |
19 | | -from ietf.name.models import FormalLanguageName, DocRelationshipName |
| 17 | +from ietf.name.models import FormalLanguageName, DocRelationshipName, CountryName |
| 18 | +from ietf.stats.models import MeetingRegistration, CountryAlias |
| 19 | +from ietf.stats.utils import get_meeting_registration_data |
20 | 20 |
|
21 | 21 | class StatisticsTests(TestCase): |
22 | 22 | def test_stats_index(self): |
@@ -98,6 +98,42 @@ def test_document_stats(self): |
98 | 98 | if not stats_type.startswith("yearly"): |
99 | 99 | self.assertTrue(q('table.stats-data')) |
100 | 100 |
|
| 101 | + def test_meeting_stats(self): |
| 102 | + # create some data for the statistics |
| 103 | + make_test_data() |
| 104 | + meeting = MeetingFactory(type_id='ietf', date=datetime.date.today(), number="96") |
| 105 | + MeetingRegistration.objects.create(first_name='John', last_name='Smith', country_code='US', meeting=meeting) |
| 106 | + CountryAlias.objects.get_or_create(alias="US", country=CountryName.objects.get(slug="US")) |
| 107 | + MeetingRegistration.objects.create(first_name='Jaume', last_name='Guillaume', country_code='FR', meeting=meeting) |
| 108 | + CountryAlias.objects.get_or_create(alias="FR", country=CountryName.objects.get(slug="FR")) |
| 109 | + |
| 110 | + # check redirect |
| 111 | + url = urlreverse(ietf.stats.views.meeting_stats) |
| 112 | + |
| 113 | + authors_url = urlreverse(ietf.stats.views.meeting_stats, kwargs={ "stats_type": "overview" }) |
| 114 | + |
| 115 | + r = self.client.get(url) |
| 116 | + self.assertEqual(r.status_code, 302) |
| 117 | + self.assertTrue(authors_url in r["Location"]) |
| 118 | + |
| 119 | + # check various stats types |
| 120 | + for stats_type in ["overview", "country", "continent"]: |
| 121 | + url = urlreverse(ietf.stats.views.meeting_stats, kwargs={ "stats_type": stats_type }) |
| 122 | + r = self.client.get(url) |
| 123 | + self.assertEqual(r.status_code, 200) |
| 124 | + q = PyQuery(r.content) |
| 125 | + self.assertTrue(q('#chart')) |
| 126 | + if stats_type == "overview": |
| 127 | + self.assertTrue(q('table.stats-data')) |
| 128 | + |
| 129 | + for stats_type in ["country", "continent"]: |
| 130 | + url = urlreverse(ietf.stats.views.meeting_stats, kwargs={ "stats_type": stats_type, "num": meeting.number }) |
| 131 | + r = self.client.get(url) |
| 132 | + self.assertEqual(r.status_code, 200) |
| 133 | + q = PyQuery(r.content) |
| 134 | + self.assertTrue(q('#chart')) |
| 135 | + self.assertTrue(q('table.stats-data')) |
| 136 | + |
101 | 137 | def test_known_country_list(self): |
102 | 138 | make_test_data() |
103 | 139 |
|
|
0 commit comments