Ejemplo n.º 1
0
def test_vote_bill_clearing():
    # ensure that we don't wind up with votes sitting around forever on bills as changes
    # make it look like there are multiple votes
    j = Jurisdiction.objects.create(id='jid', division_id='did')
    session = j.legislative_sessions.create(name='1900', identifier='1900')
    org = Organization.objects.create(id='org-id', name='House', classification='lower')
    bill = Bill.objects.create(id='bill-1', identifier='HB 1', legislative_session=session,
                               from_organization=org)
    Bill.objects.create(id='bill-2', identifier='HB 2', legislative_session=session,
                        from_organization=org)
    dmi = DumbMockImporter()
    bi = BillImporter('jid', dmi, dmi)

    vote1 = ScrapeVote(legislative_session='1900', start_date='2013',
                       classification='anything', result='passed',
                       motion_text='a vote on somthing',             # typo intentional
                       bill=bill.identifier, bill_chamber='lower')
    vote2 = ScrapeVote(legislative_session='1900', start_date='2013',
                       classification='anything', result='passed',
                       motion_text='a vote on something else',
                       bill=bill.identifier, bill_chamber='lower')

    # have to use import_data so postimport is called
    VoteImporter('jid', dmi, dmi, bi).import_data([vote1.as_dict(), vote2.as_dict()])
    assert VoteEvent.objects.count() == 2

    # a typo is fixed, we don't want 3 votes now
    vote1.motion_text = 'a vote on something'
    VoteImporter('jid', dmi, dmi, bi).import_data([vote1.as_dict(), vote2.as_dict()])
    assert VoteEvent.objects.count() == 2
Ejemplo n.º 2
0
def test_vote_bill_clearing():
    # ensure that we don't wind up with votes sitting around forever on bills as changes
    # make it look like there are multiple votes
    j = Jurisdiction.objects.create(id='jid', division_id='did')
    session = j.legislative_sessions.create(name='1900', identifier='1900')
    org = Organization.objects.create(id='org-id',
                                      name='House',
                                      classification='lower')
    bill = Bill.objects.create(id='bill-1',
                               identifier='HB 1',
                               legislative_session=session,
                               from_organization=org)
    bill2 = Bill.objects.create(id='bill-2',
                                identifier='HB 2',
                                legislative_session=session,
                                from_organization=org)
    dmi = DumbMockImporter()
    bi = BillImporter('jid', dmi, dmi)

    vote1 = ScrapeVote(
        legislative_session='1900',
        start_date='2013',
        classification='anything',
        result='passed',
        motion_text='a vote on somthing',  # typo intentional
        bill=bill.identifier,
        bill_chamber='lower')
    vote2 = ScrapeVote(legislative_session='1900',
                       start_date='2013',
                       classification='anything',
                       result='passed',
                       motion_text='a vote on something else',
                       bill=bill.identifier,
                       bill_chamber='lower')

    # have to use import_data so postimport is called
    VoteImporter('jid', dmi, dmi,
                 bi).import_data([vote1.as_dict(),
                                  vote2.as_dict()])
    assert VoteEvent.objects.count() == 2

    # a typo is fixed, we don't want 3 votes now
    vote1.motion_text = 'a vote on something'
    VoteImporter('jid', dmi, dmi,
                 bi).import_data([vote1.as_dict(),
                                  vote2.as_dict()])
    assert VoteEvent.objects.count() == 2