Ejemplo n.º 1
0
    def test_create_or_update(self):
        data = { 'name': 'foo', 'url': 'bar' }

        City.create_or_update(data)
        self.assertEqual(1, City.objects.count())

        City.create_or_update(data)
        self.assertEqual(1, City.objects.count())
Ejemplo n.º 2
0
    def run(cls):
        response = urlopen(cls.url)
        html = response.read()

        cities = SiteParser().run(html)

        for city_data in cities:
            city = City.create_or_update(city_data)
            django_rq.enqueue(CityImporter.run, city)