Exemple #1
0
    def test_likes(self):
        c = Comment(user_id = self.uid1, game_id = self.game1_id, text="Test Text")
        c.id = 33
        db.session.add(c)
        db.session.commit()

        test_like = Like(user_id=self.uid1, comment_id=c.id)
        test_like.id = 254
        db.session.add(test_like)
        db.session.commit()
        like = Like.query.filter(Like.comment_id==33, Like.user_id==11).one()

        self.assertEqual(like.id, 254)
        self.assertEqual(like.user_id, 11)
        self.assertEqual(like.comment_id, 33)
    def setUp(self):
        """Create test user and data."""

        db.drop_all()
        db.create_all()

        self.client = app.test_client()

        self.testuser = User.signup(username="******",
                                    email="*****@*****.**",
                                    password="******")
        self.testuser_id = 25
        self.testuser.id = self.testuser_id

        g1 = Game(team_one="TestTeam",
                  team_two="TestTeam2",
                  team_one_odds=1.0,
                  team_two_odds=-1.0)
        game_id1 = 'id123'
        g1.id = game_id1

        db.session.add(g1)
        db.session.commit()

        c = Comment(user_id=self.testuser.id,
                    game_id=game_id1,
                    text="Test Text")
        c.id = 33
        db.session.add(c)
        db.session.commit()

        test_like = Like(user_id=self.testuser_id, comment_id=c.id)
        test_like.id = 254
        db.session.add(test_like)
        db.session.commit()

        self.like = Like.query.filter(Like.comment_id == 33,
                                      Like.user_id == 25).one()
        self.comment_1 = Comment.query.get(33)
        self.game_1 = Game.query.get(game_id1)
        self.game_1id = game_id1
        self.commentid = c.id