def test_data_rendering(self):
        legislator = factories.fake_legislator()
        leg_id = legislator['leg_id']

        with mock_fetch() as fetch:
            fetch.legislators.return_value = legislator
            html = render_view('openstates:legislator-detail', args=(leg_id, ))

        fetch.legislators.assert_called_once_with(leg_id)
        assert legislator['full_name'] in html
        assert legislator['district'] in html
        assert legislator['party'] in html
        assert legislator['chamber'] in html
Exemple #2
0
    def test_data_rendering(self):
        legislator = factories.fake_legislator()
        detail_url = reverse('openstates:legislator-detail',
                             args=(legislator['openstates_leg_id'], ))

        with mock_fetch() as fetch:
            fetch.legislators.return_value = [legislator]
            html = render_view('openstates:legislator-list')

        assert detail_url in html
        assert legislator['openstates_leg_id'] in html
        assert legislator['name'] in html
        assert legislator['district'] in html
        assert legislator['party'] in html
        assert legislator['chamber'] in html
Exemple #3
0
    def test_deserialize_bill_with_valid_legislator_vote(self):
        """Most tests skip vote attribution because legislators been created.

        This test adds a legislator to the database so that a vote can be attributed to that
        legislator on the given bill.
        """
        bill_data = factories.fake_bill_detail()
        legislator_data = factories.fake_legislator()
        # Attribute vote on bill to legislator.
        bill_data['votes'][0]['yes_votes'][0]['leg_id'] = legislator_data['leg_id']

        with mock.patch.object(utils, 'LOG'):
            legislator = utils.deserialize_openstates_legislator(legislator_data)
            bill = utils.deserialize_openstates_bill(bill_data)
            # Deserializing a second time should not create a second vote.
            utils.deserialize_openstates_bill(bill_data)

        assert SingleVote.objects.all().count() == 1
        vote = SingleVote.objects.all().first()
        assert vote.legislator == legislator
        assert vote.vote_tally.bill == bill