Пример #1
0
 def test_schedule_e_efile_filter_cand_search(self):
     [
         factories.ScheduleEEfileFactory(
             cand_fulltxt=sa.func.to_tsvector('C001, Rob, Senior')),
         factories.ScheduleEEfileFactory(
             cand_fulltxt=sa.func.to_tsvector('C002, Ted, Berry')),
         factories.ScheduleEEfileFactory(
             cand_fulltxt=sa.func.to_tsvector('C003, Rob, Junior')),
     ]
     factories.EFilingsFactory(file_number=123)
     db.session.flush()
     results = self._results(
         api.url_for(ScheduleEEfileView, candidate_search='Rob'))
     assert len(results) == 2
Пример #2
0
 def test_schedule_e_efile_filters(self):
     filters = [
         ('image_number', ScheduleEEfile.image_number, ['456', '789']),
         ('committee_id', ScheduleEEfile.committee_id, ['C01', 'C02']),
         ('support_oppose_indicator',
          ScheduleEEfile.support_oppose_indicator, ['S', 'O']),
         ('most_recent', ScheduleEEfile.most_recent, [True, False]),
         ('candidate_office', ScheduleEEfile.candidate_office,
          ['H', 'S', 'P']),
         ('candidate_party', ScheduleEEfile.candidate_party, ['DEM',
                                                              'REP']),
         ('candidate_office_state', ScheduleEEfile.candidate_office_state,
          ['AZ', 'AK']),
         ('candidate_office_district',
          ScheduleEEfile.candidate_office_district, ['00', '01']),
         ('filing_form', ScheduleEEfile.filing_form, ['F3X', 'F5']),
         ('is_notice', ScheduleE.is_notice, [True, False]),
     ]
     factories.EFilingsFactory(file_number=123)
     for label, column, values in filters:
         [
             factories.ScheduleEEfileFactory(**{column.key: value})
             for value in values
         ]
         results = self._results(
             api.url_for(ScheduleEEfileView, **{label: values[0]}))
         assert len(results) == 1
         assert results[0][column.key] == values[0]
Пример #3
0
 def test_schedule_e_efile_candidate_id_filter(self):
     filters = [
         ('candidate_id', ScheduleEEfile.candidate_id, ['S01', 'S02']),
     ]
     factories.EFilingsFactory(file_number=123)
     for label, column, values in filters:
         [
             factories.ScheduleEEfileFactory(**{column.key: value})
             for value in values
         ]
         results = self._results(
             api.url_for(ScheduleEEfileView, **{label: values[0]}))
         assert len(results) == 1
         assert results[0][column.key] == values[0]
Пример #4
0
 def test_filters_sched_e_efile(self):
     filters = [
         ('image_number', ScheduleEEfile.image_number, ['123', '456']),
         ('committee_id', ScheduleEEfile.committee_id, ['C01', 'C02']),
         ('support_oppose_indicator', ScheduleEEfile.support_oppose_indicator, ['S', 'O']),
     ]
     factories.EFilingsFactory(file_number=123)
     for label, column, values in filters:
         [
             factories.ScheduleEEfileFactory(**{column.key: value})
             for value in values
         ]
         results = self._results(api.url_for(ScheduleEEfileView, **{label: values[0]}))
         assert len(results) == 1
         assert results[0][column.key] == values[0]
Пример #5
0
    def test_schedule_e_efile_uses_exact_count(self, get_query_plan_mock):
        schedule_e_efile = [
            factories.ScheduleEEfileFactory() for i in range(5)
        ]
        factories.EFilingsFactory(file_number=123)
        db.session.flush()

        query = db.session.query(models.ScheduleEEfile)
        # Estimated rows = 6000000
        get_query_plan_mock.return_value = [('Seq Scan on real_efile_se_f57_vw  (cost=0.00..10.60 rows=6000000 width=1289)',)]
        resource = sched_e.ScheduleEEfileView()
        count, estimate = counts.get_count(query, db.session, resource.use_estimated_counts)
        # Always use exact count for Schedule E efile
        self.assertEqual(count, 5)
        self.assertEqual(estimate, False)