def test_ServerViewAcces_false(self): author1 = Author(host="https://newpee.herokuapp.com/") author2 = Author(host="testhost") author1.save() author2.save() test_post = Post(author=author1) test_post.save() self.assertFalse(test_post.ServerViewAcces(author2))
def test_friendViewAccess_false(self): author1 = Author() author2 = Author() author1.save() author2.save() test_post = Post(author=author1) test_post.save() self.assertFalse(test_post.friendViewAccess(author2))
def test_FriendServerViewAcess_false_not_friend_same_server(self): author1 = Author(host="https://newpee.herokuapp.com/") author2 = Author(host="https://newpee.herokuapp.com/") author1.save() author2.save() test_post = Post(author=author1) test_post.save() self.assertFalse(test_post.FriendServerViewAcess(author2))
def test_add_friend_request(self): author1 = Author() author1.save() author2 = Author() author2.save() author1.add_friend_request(author2) requests = author1.friend_requests.all() self.assertEqual(requests[0], author2)
def test_privateViewAccess_true(self): author1 = Author() author2 = Author() author1.save() author2.save() test_post = Post(author=author1) test_post.set_visible_to(author2) test_post.save() self.assertTrue(test_post.privateViewAccess(author2))
def test_remove_friend(self): author1 = Author() author2 = Author() author1.friends.add(author2) author1.save() author2.save() self.assertEqual(author1.friends.all()[0], author2) author1.remove_friend(author2) self.assertQuerysetEqual(author1.friends.all(), author1.friends.none())
def test_FriendServerViewAcess_true(self): author1 = Author(host="https://newpee.herokuapp.com/") author2 = Author(host="https://newpee.herokuapp.com/") author1.save() author2.save() author1.friends.add(author2) author2.friends.add(author1) test_post = Post(author=author1) test_post.save() self.assertTrue(test_post.FriendServerViewAcess(author2))
def test_friendViewAccess_true(self): author1 = Author() author2 = Author() author1.save() author2.save() author1.friends.add(author2) author2.friends.add(author1) test_post = Post(author=author1) test_post.save() self.assertTrue(test_post.friendViewAccess(author2))
def test_set_visible_to(self): author1 = Author() author2 = Author() author1.save() author2.save() test_post = Post(author=author1) #setting testpost to be visible to author2 test_post.set_visible_to(author2) test_post.save() self.assertEqual(test_post.visible_to.all()[0], author2)
def test_followed(self): #create two author object person_to_follow = Author() person_to_follow.save() person_following = Author() person_following.save() #call follow person_following.followed(person_to_follow) #assert person_to_follow and first element(there is only one) of person_following's followers list self.assertEqual(person_following.followers.all()[0], person_to_follow)
def test_get_following(self): #create two author object person_to_follow = Author() person_to_follow.save() person_following = Author() person_following.save() self.assertQuerysetEqual(person_following.following.all(), person_following.following.none()) person_following.follow(person_to_follow) following = person_following.get_following() self.assertEqual(following[0], person_to_follow)
def test_unfollow(self): #create two author object person_to_follow = Author() person_to_follow.save() person_following = Author() person_following.save() #call follow person_following.follow(person_to_follow) #assert person_to_follow and first element(there is only one) of person_following's following list self.assertEqual(person_following.following.all()[0], person_to_follow) person_following.unfollow(person_to_follow) #assert if the the following list is empty self.assertQuerysetEqual(person_following.following.all(), person_following.following.none())
def test_FOAFViewAccess_false(self): author1 = Author() author2 = Author() author3 = Author() author1.save() author2.save() author3.save() #author 1 is frineds with 2 author1.friends.add(author2) author2.friends.add(author1) test_post = Post(author=author1) test_post.save() self.assertFalse(test_post.FOAFViewAccess(author3))
def test_unlisted_true(self): author1 = Author(host="http://newpee.herokuapp.com/") author1.save() test_post = Post(author=author1, unlisted=True) test_post.save() self.assertTrue(test_post.getUnlisted())