예제 #1
0
파일: tests.py 프로젝트: sonnym/craigle
    def test_create_or_update(self):
        url = 'foo'

        Post.create_or_update(url)
        self.assertEqual(1, Post.objects.count())

        Post.create_or_update(url)
        self.assertEqual(1, Post.objects.count())
예제 #2
0
파일: models.py 프로젝트: sonnym/craigle
    def run(cls, city):
        response = urlopen(urljoin(city.url, cls.path, allow_fragments=True))
        html = response.read()

        posts = CityParser().run(city, html)

        for post_data in posts:
            post = Post.create_or_update(urljoin(city.url, post_data))
            django_rq.enqueue(PostImporter.run, post)
예제 #3
0
파일: tests.py 프로젝트: sonnym/craigle
    def test_posted_at_str(self):
        post = Post.create_or_update('foo')
        post.posted_at = datetime(2015, 1, 1, 0, 1).replace(tzinfo=utc)
        post.save()

        self.assertEqual('2015-01-01 00:01', post.posted_at_str)