def test_repeated(self): url = 'http://coolshell.cn/feed' fetch_feed(url) assert Feed.objects.count() == 1 n = Entry.objects.count() fetch_feed(url) assert Entry.objects.count() == n
def get(self, request, *args, **kwargs): do_refresh = request.data.get('refresh') feed = self.instance # import pdb; pdb.set_trace() if do_refresh: try: feed = fetch_feed(feed.feed_url) except Exception as e: return HttpResponseBadRequest(e) return self.json_response(feed.as_dict())
def test_delete(self): assert Category.objects.count() == 1 assert self.client.login(username='******', password='******') f = fetch_feed('https://weworkremotely.com/categories/2/jobs.rss') res = self.client.delete( '/reader/api/feeds/{}'.format(f.id), HTTP_X_REQUESTED_WITH='XMLHttpRequest', content_type='application/json' ) assert not Feed.objects.filter(pk=f.id).exists() assert res.status_code == 200
def post(self, request): try: url = request.data.get('url') if Feed.objects.filter(feed_url=url).exists(): return HttpResponseBadRequest('Already exists!') try: m = fetch_feed(url) return self.json_response(m.as_dict()) except Exception as e: return HttpResponseBadRequest(e) except Exception as e: return HttpResponseBadRequest(e)
def test_terry(self): url = 'http://terrytai.me/rss.xml' fetch_feed(url) assert Feed.objects.count() == 1 assert Entry.objects.count() == 10
def test_techcrunch(self): url = 'http://techcrunch.cn/feed' fetch_feed(url) assert Feed.objects.count() == 1 assert Entry.objects.count() > 0
def test_lucumr(self): url = 'http://lucumr.pocoo.org/feed.atom' fetch_feed(url) assert Feed.objects.count() == 1 assert Entry.objects.count() > 0
def test_xdite(self): url = 'http://feeds.feedburner.com/xxddite' fetch_feed(url) assert Feed.objects.count() == 1 assert Entry.objects.count() > 0
def test_coolshell(self): url = 'http://coolshell.cn/feed' fetch_feed(url) assert Feed.objects.count() == 1 assert Entry.objects.count() > 0
def test_coding_horror(self): url = 'http://blog.codinghorror.com/rss/' fetch_feed(url) assert Feed.objects.count() == 1 assert Entry.objects.count() > 0
def test_chinese_feed(self): url = 'http://codingnow.com/atom.xml' fetch_feed(url) assert Feed.objects.count() == 1 assert Entry.objects.count() > 0
def test_yc_feed(self): url = 'https://news.ycombinator.com/rss' f = fetch_feed(url) assert Feed.objects.count() == 1
def test_fetch_feed(self): url = 'https://weworkremotely.com/categories/2-programming/jobs.rss' fetch_feed(url) assert Category.objects.count() == 1 assert Feed.objects.count() == 1