def setUp(self): self.c = Client() self.author_A = Author.signup("author_A", "pw", "pw") self.author_B = Author.signup("author_B", "pw", "pw") self.author_A.is_active = True self.author_B.is_active = True self.posts = [ Post.objects.create(date=datetime.date.today(), title="a", content="a", author=self.author_A, privacy=Privacy.PUBLIC), Post.objects.create(date=datetime.date.today(), title="b", content="b", author=self.author_A, privacy=Privacy.PUBLIC), Post.objects.create(date=datetime.date.today(), title="c", content="c", author=self.author_B, privacy=Privacy.PUBLIC) ]
def setUp(self): self.author_A = Author.signup("a", "pw", "pw") self.author_B = Author.signup("b", "pw", "pw") self.post = Post.objects.create(date=datetime.date.today(), title="a", content="a", author=self.author_A, privacy=Privacy.PUBLIC)
def setUp(self): self.author_A = Author.signup("a", "pw", "pw") self.author_B = Author.signup("b", "pw", "pw") self.author_C = Author.signup("c", "pw", "pw") self.author_A.follow(self.author_B) self.author_B.follow(self.author_A) self.author_C.follow(self.author_A)
def setUp(self): self.c = Client() self.author_A = Author.signup("author_A", "pw", "pw") self.author_B = Author.signup("author_B", "pw", "pw") self.author_C = Author.signup("author_C", "pw", "pw") self.author_A.follow(self.author_B) self.author_B.follow(self.author_A) self.author_A.follow(self.author_C) self.author_C.follow(self.author_A)
def test_friends_posts(self): author_C = Author.signup("c", "pw", "pw") author_D = Author.signup("d", "pw", "pw") author_E = Author.signup("e", "pw", "pw") author_C.follow(author_D) author_D.follow(author_C) self.assertTrue(author_C.friends_with(author_D)) cfs = list(author_C.get_friends()) self.assertEqual(1, len(cfs)) self.assertTrue(author_D in cfs) dfs = list(author_D.get_friends()) self.assertEqual(1, len(dfs)) self.assertTrue(author_C in dfs) author_C.follow(author_E) author_E.follow(author_C) self.assertTrue(author_C.friends_with(author_E)) post_D = Post.objects.create(date=datetime.date.today(), title="a", content="a", author=author_D) post_E = Post.objects.create(date=datetime.date.today(), title="a", content="a", author=author_E) post_E_private = Post.objects.create(date=datetime.date.today(), title="a", content="a", author=author_E, privacy=Privacy.PRIVATE) post_D_url = Post.objects.create(date=datetime.date.today(), title="a", content="a", author=author_D, privacy=Privacy.URL_ONLY) fps = list(author_C.friends_posts()) self.assertEqual(2, len(fps)) self.assertTrue(post_D in fps) self.assertTrue(post_E in fps)
def setUp(self): self.c = Client(HTTP_AUTHORIZATION="Basic YXV0aG9yOnB3") self.author = Author.signup("author", "pw", "pw") u = User.objects.get(username='******') u.is_active = True u.save() self.post = Post.objects.create(date=datetime.date.today(), title="a", content="a", author=self.author, privacy=Privacy.PUBLIC)
def test_follow(self): author_A = Author.signup("a", "pw", "pw") author_B = Author.signup("b", "pw", "pw") self.assertFalse(author_A.follows(author_B)) self.assertFalse(author_B.follows(author_A)) self.assertFalse(author_B.friends_with(author_A)) self.assertFalse(author_A.friends_with(author_B)) author_A.follow(author_B) self.assertTrue(author_A.follows(author_B)) self.assertFalse(author_B.follows(author_A)) self.assertFalse(author_B.friends_with(author_A)) self.assertFalse(author_A.friends_with(author_B)) author_B.follow(author_A) self.assertTrue(author_A.follows(author_B)) self.assertTrue(author_B.follows(author_A)) self.assertTrue(author_B.friends_with(author_A)) self.assertTrue(author_A.friends_with(author_B))
def setUp(self): self.c = Client() self.author = Author.signup("author", "pw", "pw") self.posts = [ Post.objects.create(date=datetime.date.today(), title="a", content="a", author=self.author, privacy=Privacy.PUBLIC), Post.objects.create(date=datetime.date.today(), title="b", content="b", author=self.author, privacy=Privacy.PUBLIC), Post.objects.create(date=datetime.date.today(), title="c", content="c", author=self.author, privacy=Privacy.PUBLIC) ]
def setUp(self): self.c = Client() self.author_A = Author.signup("author_A", "pw", "pw") self.author_B = Author.signup("author_B", "pw", "pw")
def setUp(self): self.author_A = Author.signup("a", "pw", "pw")
def test_passwords_dont_match(self): try: Author.signup("c", "x", "y") self.fail() except Author.PasswordsDontMatch: pass
def test_username_taken(self): try: Author.signup("a", "x", "x") self.fail() except Author.UserNameTaken: pass
def test_normal_signup(self): a = Author.signup("b", "x", "x") self.assertTrue(isinstance(a, Author))