예제 #1
0
파일: tests.py 프로젝트: sonnym/craigle
    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())
예제 #2
0
파일: models.py 프로젝트: sonnym/craigle
    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)