Coverage for tests/test_app_creation.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-20 21:23 +0000

1from app.models import User 

2from app import db 

3 

4 

5def test_testing(client): 

6 """ 

7 Author: Troy Witmer 

8 Description: simple testing route that checks the "/" route and sees if title is in the html response 

9 """ 

10 response = client.get("/") 

11 assert b"title" in response.data 

12 

13 

14def test_user_table(app): 

15 """ 

16 Author: Troy Witmer 

17 Description: Test route to assure User table exists 

18 """ 

19 with app.app_context(): 

20 assert User.query.count() == 0 

21 

22 

23def test_user_table_with_user(app): 

24 with app.app_context(): 

25 user = User(username="test") 

26 db.session.add(user) 

27 db.session.commit() 

28 

29 assert User.query.count() == 1 

30 assert User.query.filter_by(username="test").first() 

31 

32 

33def test_user_table_password(app): 

34 with app.app_context(): 

35 user = User(username="test") 

36 db.session.add(user) 

37 db.session.flush() 

38 user.set_password("test") 

39 db.session.add(user) 

40 db.session.commit() 

41 

42 user = User.query.filter_by(username="test").first() 

43 

44 assert user.check_password("test") 

45 assert not user.check_password("hello")