Ejemplo n.º 1
0
 def setUp(self):
     super(TestFilter, self).setUp()
     self.receipts = [
         factories.ScheduleAFactory(entity_type=None),
         factories.ScheduleAFactory(entity_type='IND'),
         factories.ScheduleAFactory(entity_type='CCM'),
         factories.ScheduleAFactory(entity_type='COM'),
         factories.ScheduleAFactory(entity_type='PAC'),
     ]
     self.dates = [
         factories.CalendarDateFactory(event_id=123, calendar_category_id=1, summary='July Quarterly Report Due'),
         factories.CalendarDateFactory(event_id=321, calendar_category_id=1, summary='TX Primary Runoff'),
         factories.CalendarDateFactory(event_id=111, calendar_category_id=2, summary='EC Reporting Period'),
         factories.CalendarDateFactory(event_id=222, calendar_category_id=2, summary='IE Reporting Period'),
         factories.CalendarDateFactory(event_id=333, calendar_category_id=3, summary='Executive Session'),
     ]
     self.reports = [
         factories.ReportsHouseSenateFactory(means_filed='e-file'),
         factories.ReportsHouseSenateFactory(means_filed='paper'),
     ]
     self.committees = [
         factories.CommitteeFactory(designation='P'),
         factories.CommitteeFactory(designation='P'),
         factories.CommitteeFactory(designation='B'),
         factories.CommitteeFactory(designation='U'),
     ]
Ejemplo n.º 2
0
 def setUp(self):
     super(TestFilterMatch, self).setUp()
     self.dates = [
         factories.CalendarDateFactory(
             event_id=123,
             calendar_category_id=1,
             summary='July Quarterly Report Due',
         ),
         factories.CalendarDateFactory(event_id=321,
                                       calendar_category_id=1,
                                       summary='TX Primary Runoff'),
         factories.CalendarDateFactory(event_id=111,
                                       calendar_category_id=2,
                                       summary='EC Reporting Period'),
         factories.CalendarDateFactory(event_id=222,
                                       calendar_category_id=2,
                                       summary='IE Reporting Period'),
         factories.CalendarDateFactory(event_id=333,
                                       calendar_category_id=3,
                                       summary='Executive Session'),
         factories.CalendarDateFactory(calendar_category_id=3,
                                       summary='Missing ID'),
     ]
     self.reports = [
         factories.ReportsHouseSenateFactory(means_filed='e-file'),
         factories.ReportsHouseSenateFactory(means_filed='paper'),
         factories.ReportsHouseSenateFactory(),
     ]
Ejemplo n.º 3
0
 def test_reports_by_committee_type_and_cycle(self):
     presidential_report_2012 = factories.ReportsPresidentialFactory(
         cycle=2012)
     presidential_report_2016 = factories.ReportsPresidentialFactory(
         cycle=2016)
     house_report_2016 = factories.ReportsHouseSenateFactory(cycle=2016)
     results = self._results(
         api.url_for(
             ReportsView,
             committee_type='presidential',
             cycle=2016,
         ))
     self._check_committee_ids(
         results,
         [presidential_report_2016],
         [presidential_report_2012, house_report_2016],
     )
     # Test repeated cycle parameter
     results = self._results(
         api.url_for(
             ReportsView,
             committee_type='presidential',
             cycle=[2016, 2018],
         ))
     self._check_committee_ids(
         results,
         [presidential_report_2016],
         [presidential_report_2012, house_report_2016],
     )
Ejemplo n.º 4
0
 def test_reports_by_committee_type(self):
     presidential_report = factories.ReportsPresidentialFactory()
     house_report = factories.ReportsHouseSenateFactory()
     results = self._results(
         api.url_for(ReportsView, committee_type='presidential'))
     self._check_committee_ids(results, [presidential_report],
                               [house_report])
Ejemplo n.º 5
0
 def test_report_type_exclude(self):
     committee = factories.CommitteeFactory(committee_type='H')
     committee_id = committee.committee_id
     factories.CommitteeHistoryFactory(
         committee_id=committee_id, committee_type='H',
     )
     factories.ReportsHouseSenateFactory(committee_id=committee_id, report_type='Q2')
     factories.ReportsHouseSenateFactory(committee_id=committee_id, report_type='M3')
     factories.ReportsHouseSenateFactory(
         committee_id=committee_id, report_type='TER'
     )
     results = self._results(
         api.url_for(
             CommitteeReportsView, committee_id=committee_id, report_type=['-M3']
         )
     )
     self.assertTrue(all(each['report_type'] in ['Q2', 'TER'] for each in results))
Ejemplo n.º 6
0
 def test_reports_sort_default(self):
     committee = factories.CommitteeFactory(committee_type='H')
     committee_id = committee.committee_id
     factories.CommitteeHistoryFactory(
         committee_id=committee_id,
         committee_type='H',
     )
     dates = [
         datetime.datetime(2015, 7, 4),
         datetime.datetime(2015, 7, 5),
     ]
     dates_formatted = [isoformat(each) for each in dates]
     factories.ReportsHouseSenateFactory(committee_id=committee_id,
                                         coverage_end_date=dates[0])
     factories.ReportsHouseSenateFactory(committee_id=committee_id,
                                         coverage_end_date=dates[1])
     results = self._results(
         api.url_for(CommitteeReportsView, committee_id=committee_id))
     self.assertEqual([each['coverage_end_date'] for each in results],
                      dates_formatted[::-1])
Ejemplo n.º 7
0
 def test_reports_sort(self):
     committee = factories.CommitteeFactory(committee_type='H')
     committee_id = committee.committee_id
     factories.CommitteeHistoryFactory(
         committee_id=committee_id,
         committee_type='H',
     )
     contributions = [0, 100]
     factories.ReportsHouseSenateFactory(
         committee_id=committee_id,
         net_contributions_period=contributions[0])
     factories.ReportsHouseSenateFactory(
         committee_id=committee_id,
         net_contributions_period=contributions[1])
     results = self._results(
         api.url_for(CommitteeReportsView,
                     committee_id=committee_id,
                     sort=['-net_contributions_period']))
     self.assertEqual(
         [each['net_contributions_period'] for each in results],
         contributions[::-1])
Ejemplo n.º 8
0
    def test_no_pdf_link_senate(self):
        """
        Old pdfs don't exist so we should not build links.
        """
        committee = factories.CommitteeFactory(committee_type='S')
        committee_id = committee.committee_id
        db.session.flush()
        number = 56789012346
        factories.ReportsHouseSenateFactory(
            report_year=1999, beginning_image_number=number, committee_id=committee_id,
        )

        results = self._results(
            api.url_for(
                ReportsView,
                committee_type='house-senate',
                beginning_image_number=number,
            )
        )
        self.assertIsNone(results[0]['pdf_url'])