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())
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)