Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
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')
Esempio n. 4
0
 def test_visitor_should_able_to_limit_timeline_size(self):
     v = TimelineVisitor(311749)
     r = v.range(limit=5)
     self.assertEquals(5, len(r['pictures']))
Esempio n. 5
0
 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)
Esempio n. 6
0
 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))
Esempio n. 7
0
 def test_visitor_should_know_min_id_after_each_visit(self):
     v = TimelineVisitor(311749)
     d = v.visit()
     self.assertTrue(v.max_id > 9999)
Esempio n. 8
0
 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())