Exemple #1
0
    def test_are_friend(self):
        objectFriend = FriendShips()
        objectFriend.dict = {"Przemek": ["Ala", "Basia", "Piotrek"]}
        objectFriend.areFriends = MagicMock()
        objectFriend.areFriends.return_value = "Basia is friend Przemek"

        objectStorage = FriendStorage()
        objectStorage.storage = objectFriend
        result = objectStorage.areFriends("Basia", "Przemek")

        self.assertEqual(result, "Basia is friend Przemek")
class FriendStorage:
    def __init__(self):
        self.storage = FriendShips()

    def makeFriends(self, person1, person2):
        return self.storage.makeFriends(person1, person2)

    def getFriendsList(self, person):
        return self.storage.getFriendsList(person)

    def areFriends(self, person1, person2):
        return self.storage.areFriends(person1, person2)
Exemple #3
0
    def test_get_friends_list_lack_person(self):
        objectFriend = FriendShips()
        objectFriend.dict = {"Przemek": ["Ala", "Basia", "Piotrek"]}
        objectFriend.areFriends = MagicMock()
        objectFriend.areFriends.side_effect = Exception(
            "This person not exist")

        objectStorage = FriendStorage()
        objectStorage.storage = objectFriend
        result = objectStorage.getFriendsList

        self.assertRaisesRegex(Exception, "This person not exist", result,
                               "Adam")