コード例 #1
0
ファイル: tests.py プロジェクト: sephcoster/mapusaurus
    def test_replacing(self):
        command = LoadGeos()
        old_geo = {
            'geoid': '1111111111', 'geo_type': Geo.TRACT_TYPE,
            'name': 'Geo in 1990', 'state': '11', 'county': '111',
            'tract': '11111', 'minlat': -1, 'maxlat': 1, 'minlon': -1,
            'maxlon': 1, 'centlat': 0, 'centlon': 0,
            'geom': MultiPolygon(
                Polygon(((0, 0), (0, 2), (-1, 2), (0, 0))),
                Polygon(((-4, -2), (-6, -1), (-2, -2), (-4, -2))))
        }
        command.save_batch([old_geo])
        # Geo save worked
        self.assertEqual(1, Geo.objects.filter(geoid='1111111111').count())

        census = Census2010Sex(total_pop=100, male=45, female=55)
        census.geoid_id = '1111111111'
        census.save()
        # Census data worked
        self.assertEqual(1, Census2010Sex.objects.all().count())

        new_geo = old_geo.copy()
        new_geo['name'] = 'Geo in 2000'
        command.save_batch([new_geo])
        # check that both models still exist
        query = Geo.objects.filter(geoid='1111111111')
        self.assertEqual(1, query.count())
        self.assertEqual('Geo in 2000', query.get().name)
        self.assertEqual(1, Census2010Sex.objects.all().count())

        Geo.objects.all().delete()
        Census2010Sex.objects.all().delete()
コード例 #2
0
ファイル: tests.py プロジェクト: fagan2888/mapusaurus
    def test_replacing(self):
        command = LoadGeos()
        old_geo = {
            'geoid':
            '1111111111',
            'geo_type':
            Geo.TRACT_TYPE,
            'name':
            'Geo in 1990',
            'year':
            '1990',
            'state':
            '11',
            'county':
            '111',
            'tract':
            '11111',
            'minlat':
            -1,
            'maxlat':
            1,
            'minlon':
            -1,
            'maxlon':
            1,
            'centlat':
            0,
            'centlon':
            0,
            'geom':
            MultiPolygon(Polygon(((0, 0), (0, 2), (-1, 2), (0, 0))),
                         Polygon(((-4, -2), (-6, -1), (-2, -2), (-4, -2))))
        }
        command.save_batch([old_geo])
        # Geo save worked
        self.assertEqual(1, Geo.objects.filter(geoid='1111111111').count())

        census = Census2010Sex(total_pop=100, male=45, female=55)
        census.geoid_id = '1111111111'
        census.save()
        # Census data worked
        self.assertEqual(1, Census2010Sex.objects.all().count())

        new_geo = old_geo.copy()
        new_geo['name'] = 'Geo in 2000'
        command.save_batch([new_geo])
        # check that both models still exist
        query = Geo.objects.filter(geoid='1111111111')
        self.assertEqual(1, query.count())
        self.assertEqual('Geo in 2000', query.get().name)
        self.assertEqual(1, Census2010Sex.objects.all().count())

        Geo.objects.all().delete()
        Census2010Sex.objects.all().delete()