예제 #1
0
 def setUp(self):
     super().setUp()
     self.candidate = factories.CandidateHistoryFactory(
         state='NY',
         district='07',
         two_year_period=2012,
         election_years=[2010, 2012],
         office='H',
     )
     self.committees = [
         factories.CommitteeHistoryFactory(cycle=2012, designation='P'),
         factories.CommitteeHistoryFactory(cycle=2012, designation='A'),
     ]
     factories.CandidateDetailFactory(
         candidate_key=self.candidate.candidate_key)
     [
         factories.CommitteeDetailFactory(committee_key=each.committee_key)
         for each in self.committees
     ]
     db.session.flush()
     factories.CandidateCommitteeLinkFactory(
         candidate_key=self.candidate.candidate_key,
         committee_key=self.committees[0].committee_key,
         election_year=2012,
     )
     factories.CandidateCommitteeLinkFactory(
         candidate_key=self.candidate.candidate_key,
         committee_key=self.committees[1].committee_key,
         election_year=2011,
     )
     self.totals = [
         factories.TotalsHouseSenateFactory(
             receipts=50,
             disbursements=75,
             committee_id=self.committees[0].committee_id,
             coverage_end_date=datetime.datetime(2012, 9, 30),
             last_beginning_image_number=123,
             last_report_type_full='Quarter Three',
             last_cash_on_hand_end_period=1979,
             last_report_year=2012,
             cycle=2012,
         ),
         factories.TotalsHouseSenateFactory(
             receipts=50,
             disbursements=75,
             committee_id=self.committees[1].committee_id,
             coverage_end_date=datetime.datetime(2012, 12, 31),
             last_beginning_image_number=456,
             last_report_type_full='Quarter Three',
             last_cash_on_hand_end_period=1979,
             last_report_year=2012,
             cycle=2012,
         ),
     ]
예제 #2
0
 def test_totals_house_senate(self):
     committee = factories.CommitteeFactory(committee_type='H')
     committee_id = committee.committee_id
     factories.CommitteeHistoryFactory(committee_id=committee_id, committee_type='H')
     [
         factories.TotalsHouseSenateFactory(committee_id=committee_id, cycle=2008),
         factories.TotalsHouseSenateFactory(committee_id=committee_id, cycle=2012),
     ]
     response = self._results(api.url_for(TotalsView, committee_id=committee_id))
     self.assertEqual(len(response), 2)
     self.assertEqual(response[0]['cycle'], 2012)
     self.assertEqual(response[1]['cycle'], 2008)
예제 #3
0
    def test_House_Senate_totals(self):
        committee_id = 'C8675310'
        transaction_coverage = factories.TransactionCoverageFactory(  # noqa
            committee_id=committee_id, fec_election_year=2016)
        history = factories.CommitteeHistoryFactory(  # noqa
            committee_id=committee_id,
            committee_type='S',
        )

        house_senate_fields = {
            'committee_id': committee_id,
            'cycle': 2016,
            'all_other_loans': 1,
            'candidate_contribution': 2,
            'loan_repayments': 3,
            'loan_repayments_candidate_loans': 4,
            'loan_repayments_other_loans': 5,
            'loans': 6,
            'loans_made_by_candidate': 7,
            'other_receipts': 8,
            'transfers_from_other_authorized_committee': 9,
            'transfers_to_other_authorized_committee': 10,
            'net_contributions': 127,
            'net_operating_expenditures': 128,
        }
        fields = utils.extend(house_senate_fields, shared_fields)
        committee_total = factories.TotalsHouseSenateFactory(**fields)  # noqa

        fields = utils.extend(fields, transaction_coverage_fields)

        results = self._results(
            api.url_for(TotalsCommitteeView, committee_id=committee_id))
        self.assertEqual(results[0], fields)
예제 #4
0
    def test_House_Senate_Jointed_totals(self):
        committee_id = 'C009'
        history = factories.CommitteeHistoryFactory(  # noqa
            committee_id=committee_id,
            committee_type='S',
        )

        house_senate_fields = {
            'committee_id': committee_id,
            'cycle': 2016,
            'all_other_loans': 1,
            'candidate_contribution': 2,
            'loan_repayments': 3,
            'loan_repayments_candidate_loans': 4,
            'loan_repayments_other_loans': 5,
            'committee_type': 'S',
            'committee_designation': 'J',
        }

        committee_total = factories.TotalsHouseSenateFactory(
            **house_senate_fields)  # noqa
        results = self._results(
            api.url_for(TotalsCommitteeView, committee_id=committee_id))

        self.assertEqual(len(results), 1)
예제 #5
0
    def test_House_Senate_totals(self):
        committee_id = 'C8675310'
        history = factories.CommitteeHistoryFactory(
            committee_id=committee_id,
            committee_type='S',
        )

        house_senate_fields = {
            'committee_id': committee_id,
            'cycle': 2016,
            'all_other_loans': 1,
            'candidate_contribution': 2,
            'loan_repayments': 3,
            'loan_repayments_candidate_loans': 4,
            'loan_repayments_other_loans': 5,
            'loans': 6,
            'loans_made_by_candidate': 7,
            'other_receipts': 8,
            'transfers_from_other_authorized_committee': 9,
            'transfers_to_other_authorized_committee': 10,
        }
        fields = utils.extend(house_senate_fields, shared_fields)

        committee_total = factories.TotalsHouseSenateFactory(**fields)
        results = self._results(
            api.url_for(TotalsView, committee_id=committee_id))

        self.assertEqual(results[0], fields)
예제 #6
0
 def setUp(self):
     super().setUp()
     self.candidate = factories.CandidateDetailFactory()
     self.candidates = [
         factories.CandidateHistoryFactory(
             candidate_id=self.candidate.candidate_id,
             state='PR',
             district='00',
             two_year_period=2018,
             election_years=[2020],
             cycles=[2018, 2020],
             office='H',
             candidate_election_year=2020,
         ),
         factories.CandidateHistoryFactory(
             candidate_id=self.candidate.candidate_id,
             state='PR',
             district='00',
             two_year_period=2020,
             election_years=[2020],
             cycles=[2018, 2020],
             office='H',
             candidate_election_year=2020,
         ),
     ]
     self.committees = [
         factories.CommitteeHistoryFactory(cycle=2020, designation='P'),
         factories.CommitteeHistoryFactory(cycle=2020, designation='A'),
     ]
     [
         factories.CandidateElectionFactory(
             candidate_id=self.candidate.candidate_id,
             cand_election_year=year) for year in [2016, 2020]
     ]
     [
         factories.CommitteeDetailFactory(committee_id=each.committee_id)
         for each in self.committees
     ]
     db.session.flush()
     self.candidate_committee_links = [
         factories.CandidateCommitteeLinkFactory(
             candidate_id=self.candidate.candidate_id,
             committee_id=self.committees[0].committee_id,
             committee_designation='P',
             fec_election_year=2018,
             election_yr_to_be_included=2020,
         ),
         factories.CandidateCommitteeLinkFactory(
             candidate_id=self.candidate.candidate_id,
             committee_id=self.committees[1].committee_id,
             committee_designation='A',
             fec_election_year=2018,
             election_yr_to_be_included=2020,
         ),
         factories.CandidateCommitteeLinkFactory(
             candidate_id=self.candidate.candidate_id,
             committee_id=self.committees[0].committee_id,
             committee_designation='P',
             fec_election_year=2020,
             election_yr_to_be_included=2020,
         ),
         factories.CandidateCommitteeLinkFactory(
             candidate_id=self.candidate.candidate_id,
             committee_id=self.committees[1].committee_id,
             committee_designation='A',
             fec_election_year=2020,
             election_yr_to_be_included=2020,
         ),
     ]
     self.totals = [
         factories.TotalsHouseSenateFactory(
             receipts=50,
             disbursements=75,
             committee_id=self.committees[1].committee_id,
             coverage_end_date=datetime.datetime(2018, 12, 31),
             last_cash_on_hand_end_period=100,
             cycle=2018,
         ),
         factories.TotalsHouseSenateFactory(
             receipts=50,
             disbursements=75,
             committee_id=self.committees[1].committee_id,
             coverage_end_date=datetime.datetime(2020, 12, 31),
             last_cash_on_hand_end_period=300,
             cycle=2020,
         ),
     ]
     db.session.flush()
예제 #7
0
    def setUp(self):
        super().setUp()
        self.candidate = factories.CandidateDetailFactory()
        self.candidates = [
            factories.CandidateHistoryFactory(
                candidate_id=self.candidate.candidate_id,
                state='NY',
                two_year_period=2012,
                election_years=[2010, 2012],
                cycles=[2010, 2012],
                office='S',
                candidate_election_year=2012,
            ),
            factories.CandidateHistoryFactory(
                candidate_id=self.candidate.candidate_id,
                state='NY',
                two_year_period=2010,
                election_years=[2010, 2012],
                cycles=[2010, 2012],
                office='S',
                candidate_election_year=2012,
            ),
        ]
        self.committees = [
            factories.CommitteeHistoryFactory(cycle=2012, designation='P'),
            factories.CommitteeHistoryFactory(cycle=2012, designation='A'),
        ]
        [
            factories.CandidateElectionFactory(
                candidate_id=self.candidate.candidate_id,
                cand_election_year=year) for year in [2010, 2012]
        ]
        [
            factories.CommitteeDetailFactory(committee_id=each.committee_id)
            for each in self.committees
        ]
        db.session.flush()
        self.candidate_committee_links = [
            factories.CandidateCommitteeLinkFactory(
                candidate_id=self.candidate.candidate_id,
                committee_id=self.committees[0].committee_id,
                committee_designation='A',
                fec_election_year=2012,
                election_yr_to_be_included=2012,
            ),
            factories.CandidateCommitteeLinkFactory(
                candidate_id=self.candidate.candidate_id,
                committee_id=self.committees[1].committee_id,
                committee_designation='P',
                fec_election_year=2012,
                election_yr_to_be_included=2012,
            ),
            factories.CandidateCommitteeLinkFactory(
                candidate_id=self.candidate.candidate_id,
                committee_id=self.committees[1].committee_id,
                committee_designation='P',
                fec_election_year=2010,
                election_yr_to_be_included=2012,
            ),
            factories.CandidateCommitteeLinkFactory(
                candidate_id=self.candidate.candidate_id,
                committee_id=self.committees[1].committee_id,
                committee_designation='P',
                fec_election_year=2010,
            ),
        ]
        self.totals = [
            factories.TotalsHouseSenateFactory(
                receipts=50,
                disbursements=75,
                committee_id=self.committees[0].committee_id,
                coverage_end_date=datetime.datetime(2012, 9, 30),
                last_cash_on_hand_end_period=100,
                cycle=2012,
            ),
            factories.TotalsHouseSenateFactory(
                receipts=50,
                disbursements=75,
                committee_id=self.committees[1].committee_id,
                coverage_end_date=datetime.datetime(2012, 12, 31),
                last_cash_on_hand_end_period=100,
                cycle=2012,
            ),
            factories.TotalsHouseSenateFactory(
                receipts=50,
                disbursements=75,
                committee_id=self.committees[1].committee_id,
                coverage_end_date=datetime.datetime(2012, 12, 31),
                last_cash_on_hand_end_period=300,
                cycle=2010,
            ),
        ]

        self.president_candidate = factories.CandidateDetailFactory()
        self.president_candidates = [
            factories.CandidateHistoryFactory(
                candidate_id=self.president_candidate.candidate_id,
                state='NY',
                two_year_period=2020,
                office='P',
                candidate_inactive=False,
                candidate_election_year=2020,
            ),
            factories.CandidateHistoryFactory(
                candidate_id=self.president_candidate.candidate_id,
                state='NY',
                two_year_period=2018,
                office='P',
                candidate_inactive=False,
                candidate_election_year=2020,
            ),
        ]
        self.president_committees = [
            factories.CommitteeHistoryFactory(cycle=2020, designation='P'),
            factories.CommitteeHistoryFactory(cycle=2020, designation='J'),
        ]
        [
            factories.CandidateElectionFactory(
                candidate_id=self.president_candidate.candidate_id,
                cand_election_year=year,
            ) for year in [2016, 2020]
        ]
        [
            factories.CommitteeDetailFactory(committee_id=each.committee_id)
            for each in self.president_committees
        ]
        db.session.flush()
        self.president_candidate_committee_links = [
            factories.CandidateCommitteeLinkFactory(
                candidate_id=self.president_candidate.candidate_id,
                committee_id=self.president_committees[0].committee_id,
                committee_designation='P',
                fec_election_year=2020,
                cand_election_year=2020,
                election_yr_to_be_included=2020,
            ),
            factories.CandidateCommitteeLinkFactory(
                candidate_id=self.president_candidate.candidate_id,
                committee_id=self.president_committees[0].committee_id,
                committee_designation='P',
                fec_election_year=2018,
                cand_election_year=2020,
                election_yr_to_be_included=2020,
            ),
            factories.CandidateCommitteeLinkFactory(
                candidate_id=self.president_candidate.candidate_id,
                committee_id=self.president_committees[1].committee_id,
                committee_designation='P',
                fec_election_year=2018,
                cand_election_year=2020,
                election_yr_to_be_included=2020,
            ),
        ]

        self.presidential_totals = [
            factories.TotalsCombinedFactory(
                receipts=50,
                disbursements=75,
                committee_id=self.president_committees[0].committee_id,
                coverage_end_date=datetime.datetime(2019, 9, 30),
                last_cash_on_hand_end_period=0,
                cycle=2020,
            ),
            factories.TotalsCombinedFactory(
                receipts=1,
                disbursements=1,
                committee_id=self.president_committees[1].committee_id,
                coverage_end_date=datetime.datetime(2017, 12, 31),
                last_cash_on_hand_end_period=100,
                cycle=2018,
            ),
            factories.TotalsCombinedFactory(
                receipts=25,
                disbursements=10,
                committee_id=self.president_committees[0].committee_id,
                coverage_end_date=datetime.datetime(2017, 12, 31),
                last_cash_on_hand_end_period=300,
                cycle=2018,
            ),
        ]
예제 #8
0
 def setUp(self):
     super().setUp()
     self.candidate = factories.CandidateDetailFactory()
     self.candidates = [
         factories.CandidateHistoryFactory(
             candidate_id=self.candidate.candidate_id,
             state='NY',
             two_year_period=2012,
             election_years=[2010, 2012],
             cycles=[2010, 2012],
             office='S',
         ),
         factories.CandidateHistoryFactory(
             candidate_id=self.candidate.candidate_id,
             state='NY',
             two_year_period=2010,
             election_years=[2010, 2012],
             cycles=[2010, 2012],
             office='S',
         ),
     ]
     self.committees = [
         factories.CommitteeHistoryFactory(cycle=2012, designation='P'),
         factories.CommitteeHistoryFactory(cycle=2012, designation='A'),
     ]
     [
         factories.CandidateElectionFactory(
             candidate_id=self.candidate.candidate_id,
             cand_election_year=year) for year in [2010, 2012]
     ]
     [
         factories.CommitteeDetailFactory(committee_id=each.committee_id)
         for each in self.committees
     ]
     db.session.flush()
     factories.CandidateCommitteeLinkFactory(
         candidate_id=self.candidate.candidate_id,
         committee_id=self.committees[0].committee_id,
         committee_designation='A',
         fec_election_year=2012,
     )
     factories.CandidateCommitteeLinkFactory(
         candidate_id=self.candidate.candidate_id,
         committee_id=self.committees[1].committee_id,
         committee_designation='P',
         fec_election_year=2012,
     )
     factories.CandidateCommitteeLinkFactory(
         candidate_id=self.candidate.candidate_id,
         committee_id=self.committees[1].committee_id,
         committee_designation='P',
         fec_election_year=2010,
     )
     self.totals = [
         factories.TotalsHouseSenateFactory(
             receipts=50,
             disbursements=75,
             committee_id=self.committees[0].committee_id,
             coverage_end_date=datetime.datetime(2012, 9, 30),
             last_cash_on_hand_end_period=1979,
             cycle=2012,
         ),
         factories.TotalsHouseSenateFactory(
             receipts=50,
             disbursements=75,
             committee_id=self.committees[1].committee_id,
             coverage_end_date=datetime.datetime(2012, 12, 31),
             last_cash_on_hand_end_period=1979,
             cycle=2012,
         ),
         factories.TotalsHouseSenateFactory(
             receipts=50,
             disbursements=75,
             committee_id=self.committees[1].committee_id,
             coverage_end_date=datetime.datetime(2012, 12, 31),
             last_cash_on_hand_end_period=1979,
             cycle=2010,
         ),
     ]