|
3 | 3 | import logging |
4 | 4 | from django.test import TestCase |
5 | 5 | from osf.metrics.reporters import InstitutionalSummaryMonthlyReporter |
| 6 | +from osf.metrics.reports import InstitutionMonthlySummaryReport |
6 | 7 | from osf.metrics.utils import YearMonth |
7 | 8 | from osf_tests.factories import ( |
8 | 9 | InstitutionFactory, |
@@ -79,10 +80,10 @@ def _create_active_user(cls, institution, date_confirmed): |
79 | 80 |
|
80 | 81 | def test_report_generation(self): |
81 | 82 | reporter = InstitutionalSummaryMonthlyReporter(self._yearmonth) |
82 | | - reports = list_monthly_reports(reporter) |
83 | | - self.assertEqual(len(reports), 1) |
| 83 | + reports_raw = list_monthly_reports(reporter) |
| 84 | + self.assertEqual(len(reports_raw[0]), 2) |
84 | 85 |
|
85 | | - report = reports[0] |
| 86 | + report = next(r for r in reports_raw[0] if isinstance(r, InstitutionMonthlySummaryReport)) |
86 | 87 | self.assertEqual(report.institution_id, self._institution._id) |
87 | 88 | self.assertEqual(report.user_count, 2) # _logged_in_user and _active_user |
88 | 89 | self.assertEqual(report.public_project_count, 1) |
@@ -115,7 +116,8 @@ def test_report_generation_multiple_institutions(self): |
115 | 116 |
|
116 | 117 | # Run the reporter for the current month (February 2018) |
117 | 118 | reporter = InstitutionalSummaryMonthlyReporter(self._yearmonth) |
118 | | - reports = list_monthly_reports(reporter) |
| 119 | + reports_raw= list_monthly_reports(reporter) |
| 120 | + reports = [item for sublist in reports_raw for item in sublist if isinstance(item, InstitutionMonthlySummaryReport)] |
119 | 121 | self.assertEqual(len(reports), 3) # Reports for self._institution, institution2, institution3 |
120 | 122 |
|
121 | 123 | # Extract reports by institution |
@@ -264,7 +266,8 @@ def test_high_counts_multiple_institutions(self): |
264 | 266 | if enable_benchmarking: |
265 | 267 | reporter_start_time = time.time() |
266 | 268 | reporter = InstitutionalSummaryMonthlyReporter(self._yearmonth) |
267 | | - reports = list_monthly_reports(reporter) |
| 269 | + reports_raw = list_monthly_reports(reporter) |
| 270 | + reports = [item for sublist in reports_raw for item in sublist if isinstance(item, InstitutionMonthlySummaryReport)] |
268 | 271 | assert len(reports) == additional_institution_count + 1 |
269 | 272 |
|
270 | 273 | if enable_benchmarking: |
|
0 commit comments