Exemple #1
0
 def test_create_messages_in_reply(self):
     assert temp.Storage().messages_by_users[self.user1.uuid] == [
         self.message1.uuid, self.message2.uuid, self.message3.uuid
     ]
     assert temp.Storage().messages_by_users[self.user2.uuid] == [
         self.message2.uuid, self.message3.uuid
     ]
Exemple #2
0
 def test_create_messages(self):
     assert temp.Storage().messages_list[
         self.message1.uuid] == self.message1
     assert temp.Storage().messages_list[
         self.message2.uuid] == self.message2
     assert temp.Storage().messages_list[
         self.message3.uuid] == self.message3
Exemple #3
0
    def test_unfollow(self):
        temp.Messaging().follow(who=self.user4.uuid,
                                subscribe_to=self.user1.uuid)
        temp.Messaging().unfollow(who=self.user4.uuid,
                                  subscribe_to=self.user1.uuid)

        assert not any(temp.Storage().subscription_list.values())
        assert not any(temp.Storage().followers_back_list.values())
Exemple #4
0
    def test_follower(self):
        temp.Messaging().follow(who=self.user4.uuid,
                                subscribe_to=self.user1.uuid)

        assert self.user1.uuid in temp.Storage().subscription_list[
            self.user4.uuid]
        assert self.user4.uuid in temp.Storage().followers_back_list[
            self.user1.uuid]
Exemple #5
0
def test_adding_one_follower():
    user1 = temp.User().create()

    user2 = temp.User().create()

    user1.subscribe_to(user2)

    assert temp.Storage().subscription_list[user1.uuid] == {
        user2.uuid,
    }
    assert temp.Storage().followers_back_list[user2.uuid] == {
        user1.uuid,
    }
Exemple #6
0
    def test_user_connection(self):
        assert temp.Storage().subscription_list[self.user1.uuid] == {
            self.user2.uuid, self.user3.uuid
        }
        assert temp.Storage().subscription_list[self.user2.uuid] == set()
        assert temp.Storage().subscription_list[self.user3.uuid] == set()

        assert temp.Storage().followers_back_list[self.user2.uuid] == {
            self.user1.uuid
        }
        assert temp.Storage().followers_back_list[self.user3.uuid] == {
            self.user1.uuid
        }
Exemple #7
0
    def setup(self):
        """Runs once per class"""
        temp.Storage().clear()

        self.user1 = temp.User().create()
        self.user4 = temp.User().create()

        self.message1 = temp.Messaging().post("test", self.user1.uuid)
        self.message2 = temp.Messaging().post(
            "test", self.user1.uuid, in_reply_to_uuid=self.message1.uuid)
Exemple #8
0
class TestCircularConnection(TestHandmadeData):
    from collections import defaultdict
    temp.Storage().subscription_list = defaultdict(set)
    temp.Storage().followers_back_list = defaultdict(set)

    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_circular_connection_for_user2(self):
        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)) == 2

    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_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_clear(self):
        self.user3.subscribe_to(self.user1)
        self.user3.subscribe_to(self.user2)

        assert len(temp.Timeline().generate_timeline(self.user3)) == 3
Exemple #9
0
 def teardown_class(cls):
     """Runs at end of class"""
     temp.Storage().clear()
Exemple #10
0
def test_adding_user():
    new_user = temp.User().create()
    assert temp.Storage().users[new_user.uuid] == new_user
Exemple #11
0
 def test_no_follower(self):
     assert not any(temp.Storage().subscription_list.values())
     assert not any(temp.Storage().followers_back_list.values())
Exemple #12
0
 def test_post(self):
     assert self.message1.uuid in temp.Storage().messages_list
     assert self.message2.uuid in temp.Storage().messages_list
     assert len(temp.Storage().messages_list) == 2
Exemple #13
0
 def test_total_number_of_messages(self):
     assert len(
         temp.Storage().messages_list) == self.total_number_of_messages