コード例 #1
0
ファイル: test_us_data.py プロジェクト: kenmickles/call-power
    def setUp(self, **kwargs):
        super(TestUSData, self).setUp(**kwargs)

        self.CONGRESS_CAMPAIGN = Campaign(country_code='us',
                                          campaign_type='congress',
                                          campaign_subtype='both',
                                          target_ordering='in-order',
                                          locate_by='postal')

        # avoid geocoding round-trip
        self.mock_location = Location('Boston, MA', (42.355662, -71.065483), {
            'state': 'MA',
            'zipcode': '02111'
        })

        self.mock_location_split_parties = Location('Bakersfield, CA',
                                                    (35.375960, -119.020865), {
                                                        'state': 'MA',
                                                        'zipcode': '93301'
                                                    })

        # this zipcode pretty evenly split between KY-2 & TN-7
        self.mock_location_multiple_states = Location('Fort Campbell, KY',
                                                      (36.647207, -87.451635),
                                                      {
                                                          'state': 'KY',
                                                          'zipcode': '42223'
                                                      })

        # this zipcode pretty evenly split between WI-2 & WI-3
        self.mock_location_multiple_districts = Location(
            'Hazel Green, WI', (42.532498, -90.436727), {
                'state': 'WI',
                'zipcode': '53811'
            })
コード例 #2
0
    def test_locate_targets_incorrect_state(self):
        self.STATE_CAMPAIGN.campaign_state = 'CA'

        other_location = Location('Boston, MA', (42.355662,-71.065483),
            {'state':'MA','zipcode':'02111'})
        
        uids = locate_targets(other_location, self.STATE_CAMPAIGN, cache=self.mock_cache)
        self.assertEqual(len(uids), 0)
コード例 #3
0
    def setUp(self):
        self.STATE_CAMPAIGN = Campaign(country_code='us',
                                       campaign_type='state',
                                       campaign_subtype='both',
                                       target_ordering='in-order',
                                       locate_by='latlon')

        self.mock_location = Location('Oakland, CA', (37.804417, -122.267747),
                                      {
                                          'state': 'CA',
                                          'zipcode': '94612'
                                      })
コード例 #4
0
    def test_locate_targets_unicameral_state(self):
        self.STATE_CAMPAIGN.campaign_state = 'NE'
        self.STATE_CAMPAIGN.campaign_subtype = 'both'
        self.STATE_CAMPAIGN.target_ordering = 'lower-first'

        other_location = Location('Lincoln, NE', (40.80798, -96.69968),
            {'state':'NE','zipcode':'68508'})
        
        uids = locate_targets(other_location, self.STATE_CAMPAIGN, cache=self.mock_cache)
        self.assertEqual(len(uids), 1)

        first = self.us_data.get_uid(uids[0])
        self.assertEqual(first['chamber'], 'legislature')
コード例 #5
0
    def setUp(self, **kwargs):
        super(TestCAData, self).setUp(**kwargs)

        self.PARLIAMENT_CAMPAIGN = Campaign(country_code='ca',
                                            campaign_type='parliament',
                                            campaign_subtype='lower',
                                            target_ordering='in-order',
                                            locate_by='address')
        self.PROVINCE_CAMPAIGN = Campaign(country_code='ca',
                                          campaign_type='province',
                                          campaign_state='QC',
                                          campaign_subtype='lower',
                                          locate_by='address')

        # well, really montreal
        self.mock_location = Location('North Pole', (45.500577, -73.567427), {
            'province': 'QC',
            'postal_code': 'H0H 0H0'
        })