Coverage for tests/test_configs.py: 100%

# Coverage for tests/test_configs.py : 100%

## 39 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1"""

2 test all the different configurations types in

3 config.py

4"""

5 import pytest

6

7

8 class TestAppConfigs:

9 @pytest.mark.parametrize("app_type", ["development"])

10 def test_dev_app_config(self, app):

11

12 config = app.config

13

14 assert "ENV" in config

15 assert config["ENV"] == "development"

16 assert "DEBUG" in config

17 assert config["DEBUG"] is True

18 assert config["LOGIN_DISABLED"] is not None

19 assert "SECRET_KEY" in config

20 assert config["SECRET_KEY"] is not None

21 assert "SQLALCHEMY_DATABASE_URI" in config

22 assert config["SQLALCHEMY_DATABASE_URI"] is not None

23 assert config["MAIL_SERVER"] in ["localhost", "console"]

24 assert "MAIL_PORT" in config

25 assert "MAIL_USERNAME" in config

26 assert "MAIL_PASSWORD" in config

27 assert "MAIL_DEFAULT_SENDER" in config

28

29 @pytest.mark.parametrize("app_type", ["production"])

30 def test_prod_app_config(self, app):

31 """

32 Test the productions configs. Environment variable

33 configs(private configs) are loaded from .test.prod.env just

34 to make sure these are loaded correctly

35 """

36 config = app.config

37

38 assert "ENV" in config

39 assert config["ENV"] == "production"

40 assert "DEBUG" in config

41 assert config["DEBUG"] is False

42 assert "SECRET_KEY" in config

43 assert config["SECRET_KEY"] == "secret"

44 assert "EMAIL_CONFIRMATION_DISABLED" in config

45 assert config["MAIL_SERVER"] not in ["localhost", "console"]

46 assert "MAIL_PORT" in config

47 assert "MAIL_USERNAME" in config

48 assert config["MAIL_USERNAME"] == "foo@gmail.com"

49 assert "MAIL_PASSWORD" in config

50 assert config["MAIL_PASSWORD"] == "pass"

51 assert "MAIL_DEFAULT_SENDER" in config

52 assert config["MAIL_DEFAULT_SENDER"] == "foo@gmail.com"

53 assert "SQLALCHEMY_DATABASE_URI" in config

54 assert (

55 config["SQLALCHEMY_DATABASE_URI"]

56 == "mysql+pymysql://db_username:db_password@db_host/db_name"

57 )