-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_config.py
190 lines (144 loc) · 5.58 KB
/
test_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import os
import json
def test_postgres_config():
file_path = ".env"
assert os.path.isfile(
file_path
), f"you didn't set up an environment .env file: {file_path}"
with open(file_path, "r") as f:
env_variables = f.read()
assert (
"POSTGRES_PASSWORD" in env_variables
), f"you didn't set a POSTGRES_PASSWORD in {file_path}"
assert (
"WALG_GS_PREFIX" in env_variables
), f"you didn't set a WALG_GS_PREFIX in {file_path}"
file_path = "postgres/serviceAccountKey.json"
assert os.path.isfile(
file_path
), f"you didn't set up an service account key for wal-g and postgrs: {file_path}" # noqa E501
def test_firebase_config():
file_path = ".env"
assert os.path.isfile(
file_path
), f"you didn't set up an environment .env file: {file_path}"
with open(file_path, "r") as f:
env_variables = f.read() # .split('\n')
assert (
"FIREBASE_TOKEN" in env_variables
), f"you did not set a firebase token in {file_path}"
def test_mapswipe_workers_service_account():
# test serviceAccountKey
file_path = "mapswipe_workers/config/serviceAccountKey.json"
assert os.path.isfile(
file_path
), f"you didn't set up config file: {file_path}" # noqa E501
def test_mapswipe_workers_configuration():
file_path = "mapswipe_workers/config/configuration.json"
assert os.path.isfile(
file_path
), f"you didn't set up config file: {file_path}" # noqa E501
with open(file_path, "r") as f:
configuration = json.load(f)
# test postgres config
assert configuration.get(
"postgres", None
), f"you didn't set postgres config in {file_path}"
assert configuration.get("postgres", {}).get(
"host", None
), f"you didn't set postgres host in {file_path}"
assert configuration.get("postgres", {}).get(
"port", None
), f"you didn't set postgres host in {file_path}"
assert configuration.get("postgres", {}).get(
"database", None
), f"you didn't set postgres database in {file_path}"
assert configuration.get("postgres", {}).get(
"username", None
), f"you didn't set postgres username in {file_path}"
assert configuration.get("postgres", {}).get(
"password", None
), f"you didn't set postgres password in {file_path}"
# test firebase config
assert configuration.get(
"firebase", None
), f"you didn't set firebase config in {file_path}"
assert configuration.get("firebase", {}).get(
"database_name", None
), f"you didn't set firebase database_name in {file_path}"
assert configuration.get("firebase", {}).get(
"api_key", None
), f"you didn't set firebase api_key in {file_path}"
# test firebase config
assert configuration.get(
"firebase", None
), f"you didn't set firebase config in {file_path}"
assert configuration.get("firebase", {}).get(
"database_name", None
), f"you didn't set firebase database_name in {file_path}"
assert configuration.get("firebase", {}).get(
"api_key", None
), f"you didn't set firebase api_key in {file_path}"
# test imagery, we test only for bing now
assert configuration.get(
"imagery", None
), f"you didn't set imagery config in {file_path}"
assert configuration.get("imagery", {}).get(
"bing", None
), f"you didn't set bing imagery config in {file_path}"
assert (
configuration.get("imagery", {}).get("bing", {}).get("url", None)
), f"you didn't set bing imagery url in {file_path}"
assert (
configuration.get("imagery", {}).get("bing", {}).get("api_key", None)
), f"you didn't set bing imagery api_key in {file_path}"
# test sentry config
assert configuration.get(
"sentry", None
), f"you didn't set sentry config in {file_path}"
assert configuration.get("sentry", {}).get(
"dsn", None
), f"you didn't set sentry dsn value in {file_path}"
# test slack config
assert configuration.get(
"slack", None
), f"you didn't set slack config in {file_path}"
assert configuration.get("slack", {}).get(
"token", None
), f"you didn't set slack token in {file_path}"
assert configuration.get("slack", {}).get(
"channel", None
), f"you didn't set slack channel in {file_path}"
assert configuration.get("slack", {}).get(
"username", None
), f"you didn't set slack username in {file_path}"
def test_manager_dashboard_config():
file_path = "manager_dashboard/manager_dashboard/js/app.js"
assert os.path.isfile(
file_path
), f"you didn't set up config file: {file_path}" # noqa E501
with open(file_path, "r") as f:
app_config = f.read()
assert (
"apiKey" in app_config
), f"you didn't set manager_dashboard firebase apiKey in: {file_path}"
assert (
"authDomain" in app_config
), f"you didn't set manager_dashboard firebase authDomain in: {file_path}"
assert (
"databaseURL" in app_config
), f"you didn't set manager_dashboard firebase databaseURL in: {file_path}"
assert "storageBucket" in app_config, (
f"you didn't set manager_dashboard firebase storageBucket in:"
f"{file_path}" # noqa E501
)
if __name__ == "__main__":
test_firebase_config()
test_postgres_config()
test_mapswipe_workers_service_account()
test_mapswipe_workers_configuration()
test_manager_dashboard_config()
print(
"your configuration looks complete. "
"However we didn't test if the values are set correct."
)