Ejemplo n.º 1
0
    def testUserCreation(self):
        '''Create user'''
        self.user = models.Users(username='******',
                                 email='*****@*****.**',
                                 password=generate_password_hash('welcome1'))

        session.add(self.user)
        session.commit()

        utest = session.query(
            models.Users).filter_by(email='*****@*****.**').first()

        self.assertEqual(utest.username, 'todd')
Ejemplo n.º 2
0
    def setUp(self):
        '''Database setUp'''
        Base.metadata.create_all(engine)

        # Create an example user
        self.user = models.Users(username="******",
                                 email="*****@*****.**",
                                 password=generate_password_hash("test"))
        session.add(self.user)
        session.commit()

        user = session.query(
            models.Users).filter_by(email='*****@*****.**').first()

        print(user.email)
        self.assertTrue(user.email, '*****@*****.**')
        self.assertTrue(user.email, '*****@*****.**')
Ejemplo n.º 3
0
    def testGoal(self):
        '''Create goal entries'''
        self.user = models.Users(username='******',
                                 email='*****@*****.**',
                                 password=generate_password_hash('welcome1'))

        session.add(self.user)
        session.commit()

        goal = models.Goals(user_id=self.user.id,
                            weight_goal=150,
                            health_goal=.5)

        session.add(goal)
        session.commit()

        gtest = session.query(models.Goals) \
            .filter_by(user_id=self.user.id) \
            .first()

        self.assertEqual(gtest.weight_goal, 150)
Ejemplo n.º 4
0
    def testWeightEntries(self):
        '''Create weight entries'''
        now = datetime.datetime.now().strftime("%Y-%m-%d")

        self.user = models.Users(username='******',
                                 email='*****@*****.**',
                                 password=generate_password_hash('welcome1'))

        session.add(self.user)
        session.commit()

        weight = models.Weight(weight=200,
                               weight_date=now,
                               user_id=self.user.id)
        session.add(weight)
        session.commit()

        testweight = session.query(models.Weight) \
            .filter_by(user_id = self.user.id) \
            .filter_by(weight=200) \
            .first()

        self.assertEqual(testweight.weight, 200)
Ejemplo n.º 5
0
    def testFoodDiary(self):
        '''Create food entries'''
        now = datetime.datetime.now().strftime("%Y-%m-%d")

        self.user = models.Users(username='******',
                                 email='*****@*****.**',
                                 password=generate_password_hash('welcome1'))

        session.add(self.user)
        session.commit()

        rank1 = models.Ranks(rank=1, rankdesc='Good')
        rank2 = models.Ranks(rank=2, rankdesc='Ok')
        rank3 = models.Ranks(rank=3, rankdesc='Bad')
        session.add_all([rank1, rank2, rank3])
        session.commit()

        food1 = models.Food(food='TEST FOOD 1',
                            food_date=now,
                            rank_id=1,
                            user_id=self.user.id)
        food2 = models.Food(food='TEST FOOD 1',
                            food_date=now,
                            rank_id=2,
                            user_id=self.user.id)
        food3 = models.Food(food='TEST FOOD 1',
                            food_date=now,
                            rank_id=3,
                            user_id=self.user.id)

        session.add_all([food1, food2, food3])
        session.commit()

        foodcount = session.query(models.Food).count()

        self.assertEqual(foodcount, 3)