def test_by_state(self): [ factories.ScheduleAByStateFactory( committee_id=self.committees[0].committee_id, cycle=2012, total=50, state='NY', state_full='New York', count=30, ), factories.ScheduleAByStateFactory( committee_id=self.committees[1].committee_id, cycle=2012, total=150, state='NY', state_full='New York', count=30, ), ] results = self._results( api.url_for( ScheduleAByStateCandidateView, candidate_id=self.candidate.candidate_id, cycle=2012, )) assert len(results) == 1 expected = { 'candidate_id': self.candidate.candidate_id, 'cycle': 2012, 'total': 200, 'state': 'NY', 'state_full': 'New York', 'count': 30, } assert results[0] == expected
def test_by_state(self): [ factories.ScheduleAByStateFactory( committee_id=self.committees[0].committee_id, cycle=2012, total=50, state='NY', state_full='New York', ), factories.ScheduleAByStateFactory( committee_id=self.committees[1].committee_id, cycle=2012, total=150, state='NY', state_full='New York', ), ] results = self._results( api.url_for( ScheduleAByStateCandidateView, candidate_id=self.candidate.candidate_id, cycle=2012, )) self.assertEqual(len(results), 1) expected = { 'candidate_id': self.candidate.candidate_id, 'cycle': 2012, 'total': 200, 'state': 'NY', 'state_full': 'New York', } self.assertEqual(results[0], expected)
def test_by_state(self): [ factories.ScheduleAByStateFactory( committee_id='C0001', cycle=2012, total=50, state='NY', state_full='New York', count=5, ), factories.ScheduleAByStateFactory( committee_id='C0002', cycle=2012, total=150, state='NY', state_full='New York', count=6, ), factories.ScheduleAByStateFactory( committee_id='C0003', cycle=2018, total=100, state='OT', state_full='Other', ), factories.ScheduleAByStateFactory( committee_id='C0001', cycle=2016, total=200, state='CT', state_full='Connecticut', count=2, ), ] results = self._results( api.url_for(ScheduleAByStateView, committee_id='C0001', cycle=2012)) assert len(results) == 1 results = self._results(api.url_for( ScheduleAByStateView, state='NY', )) assert len(results) == 2 results = self._results( api.url_for( ScheduleAByStateView, cycle=2018, state='OT', )) assert len(results) == 1 results = self._results( api.url_for( ScheduleAByStateView, committee_id='C0001', )) assert len(results) == 2
def test_by_state_candidate_totals(self): [ factories.ScheduleAByStateFactory( committee_id=self.committees[0].committee_id, cycle=2012, total=50.3, state='NY', state_full='New York', count=30, ), factories.ScheduleAByStateFactory( committee_id=self.committees[1].committee_id, cycle=2012, total=150.11, state='CT', state_full='New York', count=10, ), factories.ScheduleAByStateFactory( committee_id=self.committees[1].committee_id, cycle=2012, total=150.10, state='NJ', state_full='New Jersey', count=60, ), ] results = self._results( api.url_for( ScheduleAByStateCandidateTotalsView, candidate_id=self.candidate.candidate_id, cycle=2012, ) ) assert len(results) == 1 expected = { 'candidate_id': self.candidate.candidate_id, 'cycle': 2012, 'total': 350.51, 'count': 100, } assert results[0] == expected