예제 #1
0
파일: tests.py 프로젝트: artsR/Microblog
    def test_follow(self):
        u1 = User(username='******', email='*****@*****.**')
        u2 = User(username='******', email='*****@*****.**')
        db.session.add(u1)
        db.session.add(u2)
        db.session.commit()
        self.assertEqual(u1.followed.all(), [])
        self.assertEqual(u1.followers.all(), [])

        u1.follow(u2)
        db.session.commit()
        self.assertTrue(u1.is_following(u2))
        self.assertEqual(u1.followed.count(), 1)
        self.assertEqual(u1.followed.first().username, 'test2')
        self.assertEqual(u2.followers.count(), 1)
        self.assertEqual(u2.followers.first().username, 'test1')

        u1.unfollow(u2)
        db.session.commit()
        self.assertFalse(u1.is_following(u2))
        self.assertEqual(u1.followed.count(), 0)
        self.assertEqual(u2.followers.count(), 0)
예제 #2
0
파일: tests.py 프로젝트: LilJohny/microblog
    def test_follow(self):
        u1 = User(username='******', email='*****@*****.**')
        u2 = User(username='******', email='*****@*****.**')
        db.session.add(u1)
        db.session.add(u2)
        db.session.commit()
        self.assertEqual(u1.followed.all(), [])
        self.assertEqual(u1.followers.all(), [])

        u1.follow(u2)
        db.session.commit()
        self.assertTrue(u1.is_following(u2))
        self.assertEqual(u1.followed.count(), 1)
        self.assertEqual(u1.followed.first().username, 'susan')
        self.assertEqual(u2.followers.count(), 1)
        self.assertEqual(u2.followers.first().username, 'john')

        u1.unfollow(u2)
        db.session.commit()
        self.assertFalse(u1.is_following(u2))
        self.assertEqual(u1.followed.count(), 0)
        self.assertEqual(u2.followers.count(), 0)
예제 #3
0
파일: tests.py 프로젝트: yuxi0203/Elvisblog
 def test_follow(self):
     u1 = User(nickname = 'john', email = '*****@*****.**')
     u2 = User(nickname = 'susan', email = '*****@*****.**')
     db.session.add(u1)
     db.session.add(u2)
     db.session.commit()
     assert u1.unfollow(u2) == None
     u = u1.follow(u2)
     db.session.add(u)
     db.session.commit()
     assert u1.follow(u2) == None
     assert u1.is_following(u2)
     assert u1.followed.count() == 1
     assert u1.followed.first().nickname == 'susan'
     assert u2.followers.count() == 1
     assert u2.followers.first().nickname == 'john'
     u = u1.unfollow(u2)
     assert u != None
     db.session.add(u)
     db.session.commit()
     assert u1.is_following(u2) == False
     assert u1.followed.count() == 0
     assert u2.followers.count() == 0
예제 #4
0
 def test_follow(self):
     u1 = User(nickname='john', email='*****@*****.**')
     u2 = User(nickname='susan', email='*****@*****.**')
     db.session.add(u1)
     db.session.add(u2)
     db.session.commit()
     assert u1.unfollow(u2) is None
     u = u1.follow(u2)
     db.session.add(u)
     db.session.commit()
     assert u1.follow(u2) is None
     assert u1.is_following(u2)
     assert u1.followed.count() == 1
     assert u1.followed.first().nickname == 'susan'
     assert u2.followers.count() == 1
     assert u2.followers.first().nickname == 'john'
     u = u1.unfollow(u2)
     assert u is not None
     db.session.add(u)
     db.session.commit()
     assert u1.is_following(u2) is False
     assert u1.followed.count() == 0
     assert u2.followers.count() == 0