Coverage for config.py: 100%

# Coverage for config.py : 100%

## 55 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 Specify main configs here

3

4 Other configs are specified in module's global.py in like

5 configs = {

6 "development": {

7 "CONFIG_VAR": "DEVVALUE"

8 },

9 "production": {

10 "CONFIG_VAR": "PRODVALUE"

11 },

12 "testing": {

13 "CONFIG_VAR": "TESTVALUE"

14 }

15}

16"""

17 import os

18

19 base_path = os.path.dirname(os.path.abspath(__file__))

20

21

22 class BaseConfig:

23 """Parent configuration class."""

24

25 DEBUG = False

26 SQLALCHEMY_TRACK_MODIFICATIONS = False

27 BASE_DIR = base_path

28 STATIC = os.path.join(base_path, "static")

29 UPLOADED_PATH_IMAGE = os.path.join(STATIC, "uploads", "images")

30 UPLOADED_PATH_THUMB = os.path.join(STATIC, "uploads", "thumbs")

31

32

33 class ProductionConfig(BaseConfig):

34 """Configurations for production"""

35

36 # built in flask configs

37 ENV = "production"

38 SECRET_KEY = os.environ.get("SECRET_KEY")

39

40 # control email confirmation for user registration

41 EMAIL_CONFIRMATION_DISABLED = False

42

43 # flask-mailman configs

44 MAIL_SERVER = "smtp.googlemail.com"

45 MAIL_PORT = 465

46 MAIL_USE_TLS = False

47 MAIL_USE_SSL = True

48 MAIL_USERNAME = os.environ.get("MAIL_USERNAME")

49 MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD")

50 MAIL_DEFAULT_SENDER = os.environ.get("MAIL_DEFAULT_SENDER")

51

52 # database configs

53 SQLALCHEMY_DATABASE_URI = (

54 os.environ.get("SQLALCHEMY_DATABASE_URI") or "sqlite:///shopyo.db"

55 )

56

57

58 class DevelopmentConfig(BaseConfig):

59 """Configurations for development"""

60

61 # built in flask configs

62 ENV = "development"

63 DEBUG = True

64 LOGIN_DISABLED = False

65 SECRET_KEY = "secret"

66

67 # control email confirmation for user registration

68 EMAIL_CONFIRMATION_DISABLED = False

69

70 # flask-mailman configs

71 MAIL_SERVER = "localhost"

72 MAIL_PORT = 1025

73 MAIL_USE_TLS = False

74 MAIL_USE_SSL = False

75 MAIL_USERNAME = ""

76 MAIL_PASSWORD = ""

77 MAIL_DEFAULT_SENDER = "ma@mail.com"

78

79 # database configs

80 SQLALCHEMY_DATABASE_URI = "sqlite:///shopyo.db"

81

82 # unknown configs

83 PASSWORD_SALT = "some pasword salt"

84

85

86 class TestingConfig(BaseConfig):

87 """Configurations for testsing"""

88

89 # built in flask configs

90 ENV = "testing"

91 TESTING = True

92 DEBUG = True

93 SERVER_NAME = "localhost.com"

94 SECRET_KEY = "secret"

95 PREFERRED_URL_SCHEME = "http"

96

97 # flask WTF configs

98 WTF_CSRF_ENABLED = False

99

100 # control email confirmation for user registration

101 EMAIL_CONFIRMATION_DISABLED = False

102

103 # flask-mailman configs

104 MAIL_BACKEND = "console"

105 MAIL_USERNAME = "shopyofrom@test.com"

106 MAIL_PASSWORD = "pass"

107 MAIL_DEFAULT_SENDER = "shopyofrom@test.com"

108

109 # flask sqlalchemy configs

110 SQLALCHEMY_DATABASE_URI = "sqlite:///testing.db"

111

112 # flask bycrpt configs

113 BCRYPT_LOG_ROUNDS = 4

114

115 # unknown configs

116 PASSWORD_SALT = "some pasword salt"

117 LIVESERVER_PORT = 8943

118 LIVESERVER_TIMEOUT = 10

119

120

121 app_config = {

122 "development": DevelopmentConfig,

123 "production": ProductionConfig,

124 "testing": TestingConfig,

125}