Beispiel #1
0
    def test_update_legislator_instance(self):
        original = LegislatorFactory()
        original_id = original.id

        api_data = data.get_sample_legislator_detail()
        legislator = utils.update_legislator_instance(original, api_data)

        testing.assert_legislator_fields_match_data(legislator, api_data)
        assert legislator.id == original_id
Beispiel #2
0
    def test_sync_func_is_successful(self):
        command = sync_legislators_from_openstate.Command()

        legislator = LegislatorFactory.build()
        success_info = ActionInfo.create(Action.ADDED, legislator)
        with mock_dependencies(command, return_sync_info=success_info) as mocked:
            command.handle(max=None, leg_ids=None)

        mocked.sync_func.assert_called_once()
        mocked.stdout.write.assert_any_call(StringContaining(legislator.first_name))
        mocked.stdout.write.assert_any_call(StringContaining(legislator.last_name))
        mocked.stdout.write.assert_any_call(StringContaining(legislator.openstates_leg_id))
Beispiel #3
0
 def test_str_with_all_names(self):
     legislator = LegislatorFactory.build(first_name='First',
                                          last_name='Last',
                                          name='Full_name')
     assert str(legislator) == 'First Middle Last Jr.'
Beispiel #4
0
 def test_chamber_label(self):
     legislator = LegislatorFactory.build(chamber='upper')
     assert legislator.chamber_label == constants.CHAMBER_LABELS[
         constants.Chamber.UPPER]
Beispiel #5
0
 def test_party_label(self):
     legislator = LegislatorFactory.build(party='D')
     assert legislator.party_label == constants.PARTY_LABELS[
         constants.Party.DEMOCRATIC]
Beispiel #6
0
 def test_str_with_only_first_and_last(self):
     legislator = LegislatorFactory.build(first_name='First',
                                          last_name='Last',
                                          name='')
     assert str(legislator) == 'First Last'
Beispiel #7
0
 def test_str_with_all_names(self):
     legislator = LegislatorFactory.build(first_name='First',
                                          last_name='Last',
                                          middle_name='Middle',
                                          suffixes='Jr.')
     assert str(legislator) == 'First Middle Last Jr.'