Skip to content

Commit cb10694

Browse files
committed
do not test nginx config
1 parent cd2f1c0 commit cb10694

File tree

1 file changed

+122
-119
lines changed

1 file changed

+122
-119
lines changed

test_config.py

Lines changed: 122 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -3,185 +3,188 @@
33

44

55
def test_postgres_config():
6-
file_path = '.env'
7-
assert os.path.isfile(file_path), \
8-
f"you didn't set up an environment .env file: {file_path}"
6+
file_path = ".env"
7+
assert os.path.isfile(
8+
file_path
9+
), f"you didn't set up an environment .env file: {file_path}"
910

10-
with open(file_path, 'r') as f:
11+
with open(file_path, "r") as f:
1112
env_variables = f.read()
1213

13-
assert 'POSTGRES_PASSWORD' in env_variables, \
14-
f"you didn't set a POSTGRES_PASSWORD in {file_path}"
14+
assert (
15+
"POSTGRES_PASSWORD" in env_variables
16+
), f"you didn't set a POSTGRES_PASSWORD in {file_path}"
1517

16-
assert 'WALG_GS_PREFIX' in env_variables, \
17-
f"you didn't set a WALG_GS_PREFIX in {file_path}"
18+
assert (
19+
"WALG_GS_PREFIX" in env_variables
20+
), f"you didn't set a WALG_GS_PREFIX in {file_path}"
1821

19-
file_path = 'postgres/serviceAccountKey.json'
20-
assert os.path.isfile(file_path), \
21-
f"you didn't set up an service account key for wal-g and postgrs: {file_path}"
22+
file_path = "postgres/serviceAccountKey.json"
23+
assert os.path.isfile(
24+
file_path
25+
), f"you didn't set up an service account key for wal-g and postgrs: {file_path}" # noqa E501
2226

2327

2428
def test_firebase_config():
25-
file_path = '.env'
26-
assert os.path.isfile(file_path), \
27-
f"you didn't set up an environment .env file: {file_path}"
29+
file_path = ".env"
30+
assert os.path.isfile(
31+
file_path
32+
), f"you didn't set up an environment .env file: {file_path}"
2833

29-
with open(file_path, 'r') as f:
30-
env_variables = f.read() # .split('\n')
34+
with open(file_path, "r") as f:
35+
env_variables = f.read() # .split('\n')
3136

32-
assert 'FIREBASE_TOKEN' in env_variables, \
33-
f"you did not set a firebase token in {file_path}"
37+
assert (
38+
"FIREBASE_TOKEN" in env_variables
39+
), f"you did not set a firebase token in {file_path}"
3440

3541

3642
def test_mapswipe_workers_service_account():
3743
# test serviceAccountKey
38-
file_path = 'mapswipe_workers/config/serviceAccountKey.json'
39-
assert os.path.isfile(file_path), \
40-
f"you didn't set up config file: {file_path}"
44+
file_path = "mapswipe_workers/config/serviceAccountKey.json"
45+
assert os.path.isfile(
46+
file_path
47+
), f"you didn't set up config file: {file_path}" # noqa E501
4148

4249

4350
def test_mapswipe_workers_configuration():
44-
file_path = 'mapswipe_workers/config/configuration.json'
45-
assert os.path.isfile(file_path), \
46-
f"you didn't set up config file: {file_path}"
51+
file_path = "mapswipe_workers/config/configuration.json"
52+
assert os.path.isfile(
53+
file_path
54+
), f"you didn't set up config file: {file_path}" # noqa E501
4755

48-
with open(file_path, 'r') as f:
56+
with open(file_path, "r") as f:
4957
configuration = json.load(f)
5058

5159
# test postgres config
52-
assert configuration.get('postgres', None), \
53-
f"you didn't set postgres config in {file_path}"
60+
assert configuration.get(
61+
"postgres", None
62+
), f"you didn't set postgres config in {file_path}"
5463

55-
assert configuration.get('postgres', {}).get('host', None), \
56-
f"you didn't set postgres host in {file_path}"
64+
assert configuration.get("postgres", {}).get(
65+
"host", None
66+
), f"you didn't set postgres host in {file_path}"
5767

58-
assert configuration.get('postgres', {}).get('port', None), \
59-
f"you didn't set postgres host in {file_path}"
68+
assert configuration.get("postgres", {}).get(
69+
"port", None
70+
), f"you didn't set postgres host in {file_path}"
6071

61-
assert configuration.get('postgres', {}).get('database', None), \
62-
f"you didn't set postgres database in {file_path}"
72+
assert configuration.get("postgres", {}).get(
73+
"database", None
74+
), f"you didn't set postgres database in {file_path}"
6375

64-
assert configuration.get('postgres', {}).get('username', None), \
65-
f"you didn't set postgres username in {file_path}"
76+
assert configuration.get("postgres", {}).get(
77+
"username", None
78+
), f"you didn't set postgres username in {file_path}"
6679

67-
assert configuration.get('postgres', {}).get('password', None), \
68-
f"you didn't set postgres password in {file_path}"
80+
assert configuration.get("postgres", {}).get(
81+
"password", None
82+
), f"you didn't set postgres password in {file_path}"
6983

7084
# test firebase config
71-
assert configuration.get('firebase', None), \
72-
f"you didn't set firebase config in {file_path}"
85+
assert configuration.get(
86+
"firebase", None
87+
), f"you didn't set firebase config in {file_path}"
7388

74-
assert configuration.get('firebase', {}).get('database_name', None), \
75-
f"you didn't set firebase database_name in {file_path}"
89+
assert configuration.get("firebase", {}).get(
90+
"database_name", None
91+
), f"you didn't set firebase database_name in {file_path}"
7692

77-
assert configuration.get('firebase', {}).get('api_key', None), \
78-
f"you didn't set firebase api_key in {file_path}"
93+
assert configuration.get("firebase", {}).get(
94+
"api_key", None
95+
), f"you didn't set firebase api_key in {file_path}"
7996

8097
# test firebase config
81-
assert configuration.get('firebase', None), \
82-
f"you didn't set firebase config in {file_path}"
98+
assert configuration.get(
99+
"firebase", None
100+
), f"you didn't set firebase config in {file_path}"
83101

84-
assert configuration.get('firebase', {}).get('database_name', None), \
85-
f"you didn't set firebase database_name in {file_path}"
102+
assert configuration.get("firebase", {}).get(
103+
"database_name", None
104+
), f"you didn't set firebase database_name in {file_path}"
86105

87-
assert configuration.get('firebase', {}).get('api_key', None), \
88-
f"you didn't set firebase api_key in {file_path}"
106+
assert configuration.get("firebase", {}).get(
107+
"api_key", None
108+
), f"you didn't set firebase api_key in {file_path}"
89109

90110
# test imagery, we test only for bing now
91-
assert configuration.get('imagery', None), \
92-
f"you didn't set imagery config in {file_path}"
111+
assert configuration.get(
112+
"imagery", None
113+
), f"you didn't set imagery config in {file_path}"
93114

94-
assert configuration.get('imagery', {}).get('bing', None), \
95-
f"you didn't set bing imagery config in {file_path}"
115+
assert configuration.get("imagery", {}).get(
116+
"bing", None
117+
), f"you didn't set bing imagery config in {file_path}"
96118

97-
assert configuration.get('imagery', {}).get('bing', {}).get('url', None), \
98-
f"you didn't set bing imagery url in {file_path}"
119+
assert (
120+
configuration.get("imagery", {}).get("bing", {}).get("url", None)
121+
), f"you didn't set bing imagery url in {file_path}"
99122

100-
assert configuration.get('imagery', {}).get('bing', {}).get('api_key', None), \
101-
f"you didn't set bing imagery api_key in {file_path}"
123+
assert (
124+
configuration.get("imagery", {}).get("bing", {}).get("api_key", None)
125+
), f"you didn't set bing imagery api_key in {file_path}"
102126

103127
# test sentry config
104-
assert configuration.get('sentry', None), \
105-
f"you didn't set sentry config in {file_path}"
128+
assert configuration.get(
129+
"sentry", None
130+
), f"you didn't set sentry config in {file_path}"
106131

107-
assert configuration.get('sentry', {}).get('dsn', None), \
108-
f"you didn't set sentry dsn value in {file_path}"
132+
assert configuration.get("sentry", {}).get(
133+
"dsn", None
134+
), f"you didn't set sentry dsn value in {file_path}"
109135

110136
# test slack config
111-
assert configuration.get('slack', None), \
112-
f"you didn't set slack config in {file_path}"
137+
assert configuration.get(
138+
"slack", None
139+
), f"you didn't set slack config in {file_path}"
113140

114-
assert configuration.get('slack', {}).get('token', None), \
115-
f"you didn't set slack token in {file_path}"
141+
assert configuration.get("slack", {}).get(
142+
"token", None
143+
), f"you didn't set slack token in {file_path}"
116144

117-
assert configuration.get('slack', {}).get('channel', None), \
118-
f"you didn't set slack channel in {file_path}"
145+
assert configuration.get("slack", {}).get(
146+
"channel", None
147+
), f"you didn't set slack channel in {file_path}"
119148

120-
assert configuration.get('slack', {}).get('username', None), \
121-
f"you didn't set slack username in {file_path}"
149+
assert configuration.get("slack", {}).get(
150+
"username", None
151+
), f"you didn't set slack username in {file_path}"
122152

123153

124154
def test_manager_dashboard_config():
125-
file_path = 'manager_dashboard/manager_dashboard/js/app.js'
126-
assert os.path.isfile(file_path), \
127-
f"you didn't set up config file: {file_path}"
155+
file_path = "manager_dashboard/manager_dashboard/js/app.js"
156+
assert os.path.isfile(
157+
file_path
158+
), f"you didn't set up config file: {file_path}" # noqa E501
128159

129-
with open(file_path, 'r') as f:
160+
with open(file_path, "r") as f:
130161
app_config = f.read()
131162

132-
assert 'apiKey' in app_config, \
133-
f"you didn't set manager_dashboard firebase apiKey in: {file_path}"
163+
assert (
164+
"apiKey" in app_config
165+
), f"you didn't set manager_dashboard firebase apiKey in: {file_path}"
134166

135-
assert 'authDomain' in app_config, \
136-
f"you didn't set manager_dashboard firebase authDomain in: {file_path}"
167+
assert (
168+
"authDomain" in app_config
169+
), f"you didn't set manager_dashboard firebase authDomain in: {file_path}"
137170

138-
assert 'databaseURL' in app_config, \
139-
f"you didn't set manager_dashboard firebase databaseURL in: {file_path}"
171+
assert (
172+
"databaseURL" in app_config
173+
), f"you didn't set manager_dashboard firebase databaseURL in: {file_path}"
140174

141-
assert 'storageBucket' in app_config, \
142-
f"you didn't set manager_dashboard firebase storageBucket in: {file_path}"
175+
assert "storageBucket" in app_config, (
176+
f"you didn't set manager_dashboard firebase storageBucket in:"
177+
f"{file_path}" # noqa E501
178+
)
143179

144180

145-
def test_nginx_config():
146-
file_path = '.env'
147-
148-
with open(file_path, 'r') as f:
149-
env_variables = f.read()
150-
151-
assert 'SERVER_NAME' in env_variables, \
152-
f"you didn't set a SERVER_NAME in {file_path}"
153-
154-
for line in env_variables.split('\n'):
155-
if len(line) > 0:
156-
variable_name = line.split('=')[0]
157-
variable_value = line.split('=')[1].strip('"')
158-
if variable_name == 'SERVER_NAME':
159-
server_name = variable_value
160-
161-
file_path = 'nginx/nginx.conf'
162-
assert os.path.isfile(file_path), \
163-
f"you didn't set up config file: {file_path}"
164-
165-
with open(file_path, 'r') as f:
166-
nginx_config = f.read()
167-
168-
assert 'server_name' in nginx_config, \
169-
f"you didn't set server_name in: {file_path}"
170-
171-
file_path = f'/etc/letsencrypt/live/{server_name}/fullchain.pem'
172-
assert os.path.isfile(file_path), \
173-
f"you didn't set up ssl certificate: {file_path}"
174-
175-
file_path = f'/etc/letsencrypt/live/{server_name}/privkey.pem'
176-
assert os.path.isfile(file_path), \
177-
f"you didn't set up ssl certificate key: {file_path}"
178-
179-
180-
if __name__ == '__main__':
181+
if __name__ == "__main__":
181182
test_firebase_config()
182183
test_postgres_config()
183184
test_mapswipe_workers_service_account()
184185
test_mapswipe_workers_configuration()
185186
test_manager_dashboard_config()
186-
test_nginx_config()
187-
print("your configuration looks complete. However we didn't test if the values are set correct.")
187+
print(
188+
"your configuration looks complete. "
189+
"However we didn't test if the values are set correct."
190+
)

0 commit comments

Comments
 (0)