示例#1
0
文件: tests.py 项目: Tin/Instaproxy
 def test_min_id_should_change_after_each_step(self):
     v = TimelineVisitor(311749)
     v.visit()
     min_id_1 = v.min_id
     v.visit()
     min_id_2 = v.min_id
     self.assertNotEquals(min_id_1, min_id_2)
示例#2
0
文件: tests.py 项目: Tin/Instaproxy
 def test_visitor_should_tell_cache_time(self):
     v = TimelineVisitor(311749)
     v.get_timeline()
     today = datetime.now()
     self.assertEquals(datetime, type(v.cached_time))
     self.assertEquals(today.day, v.cached_time.day)
     self.assertEquals(today.month, v.cached_time.month)
     self.assertEquals(today.year, v.cached_time.year)
示例#3
0
文件: views.py 项目: Tin/Instaproxy
def timeline(request, user_id):
    visitor = TimelineVisitor(user_id)
    count = request.GET.get('count', '100')
    timeline = visitor.range(count=int(count))
    callback = request.GET.get('callback', None)
    response_text = json.dumps(timeline)
    if callback:
        response_text = '%s(%s);' % (callback, response_text)
    return HttpResponse(response_text,
                        mimetype='application/json')
示例#4
0
文件: tests.py 项目: Tin/Instaproxy
 def test_visitor_should_able_to_limit_timeline_size(self):
     v = TimelineVisitor(311749)
     r = v.range(limit=5)
     self.assertEquals(5, len(r['pictures']))
示例#5
0
文件: tests.py 项目: Tin/Instaproxy
 def test_visitor_should_cache_feed_result(self):
     v = TimelineVisitor(311749)
     v.clear_cache()
     self.assertFalse(v.cached)
     v.get_timeline()
     self.assertTrue(v.cached)
示例#6
0
文件: tests.py 项目: Tin/Instaproxy
 def test_should_use_max_id_as_min_id_in_update_query(self):
     v = TimelineVisitor(311749)
     v.visit()
     expected_visit_url = 'http://instagr.am/api/v1/feed/user/311749/?min_id=%s&' % v.max_id
     self.assertEquals(expected_visit_url, v.get_user_feed_url(update=True))
示例#7
0
文件: tests.py 项目: Tin/Instaproxy
 def test_visitor_should_know_min_id_after_each_visit(self):
     v = TimelineVisitor(311749)
     d = v.visit()
     self.assertTrue(v.max_id > 9999)
示例#8
0
文件: tests.py 项目: Tin/Instaproxy
 def test_there_should_have_no_max_id_in_the_begin(self):
     v = TimelineVisitor(311749)
     self.assertEquals('http://instagr.am/api/v1/feed/user/311749/?', v.get_user_feed_url())