def test_timeline_for_different_k(self): max_k = len(temp.Timeline().generate_timeline(self.user3)) print("We generated maximum of %s messages" % max_k) for k in range(0, max_k): print("Test for %s timeline limit" % k) assert len(temp.Timeline().generate_timeline(self.user3, k_limit=k)) == k
def test_circular_follow_timeline(self): # Let's start with following self self.user2.subscribe_to(self.user2) assert temp.Timeline().generate_timeline(self.user3) == [] self.user3.subscribe_to(self.user3) assert temp.Timeline().generate_timeline(self.user3) == []
def test_create_one_message(self): new_message = temp.Message(self.user2, "M4: In reply to M3", in_reply_to=self.message3.uuid) new_message.created = new_message.created + datetime.timedelta( seconds=10) new_message.post() assert len(temp.Timeline().generate_timeline(self.user1)) == 3 assert len(temp.Timeline().generate_timeline(self.user2)) == 0 assert len(temp.Timeline().generate_timeline(self.user3)) == 0
def test_clear(self): self.user3.subscribe_to(self.user1) self.user3.subscribe_to(self.user2) assert len(temp.Timeline().generate_timeline(self.user3)) == 3
def test_case_for_user2(self): self.user2.subscribe_to(self.user1) assert len(temp.Timeline().generate_timeline(self.user1)) == 2 assert len(temp.Timeline().generate_timeline(self.user2)) == 1 assert len(temp.Timeline().generate_timeline(self.user3)) == 3
def test_circular_connection_for_user3(self): self.user3.subscribe_to(self.user1) self.user3.subscribe_to(self.user2) assert len(temp.Timeline().generate_timeline(self.user1)) == 2 assert len(temp.Timeline().generate_timeline(self.user2)) == 0 assert len(temp.Timeline().generate_timeline(self.user3)) == 3
def test_timeline_for_two_followed(self): assert temp.Timeline().generate_timeline( self.user1) == [self.message3, self.message2] assert temp.Messaging().timeline( self.user1) == [self.message3, self.message2]
def test_timeline_for_zero_followed(self): assert temp.Timeline().generate_timeline(self.user2) == [] assert temp.Timeline().generate_timeline(self.user3) == [] assert temp.Messaging().timeline(self.user2) == [] assert temp.Messaging().timeline(self.user3) == []
def test_timeline_for_one_followers2(self): assert len(temp.Timeline().generate_timeline(self.user3)) <= 50
def test_timeline_subscribed_to_zero(self): assert temp.Timeline().generate_timeline(self.user2) == [] assert temp.Timeline().generate_timeline(self.user3) == []