|
3 | 3 |
|
4 | 4 |
|
5 | 5 | 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}" |
9 | 10 |
|
10 | | - with open(file_path, 'r') as f: |
| 11 | + with open(file_path, "r") as f: |
11 | 12 | env_variables = f.read() |
12 | 13 |
|
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}" |
15 | 17 |
|
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}" |
18 | 21 |
|
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 |
22 | 26 |
|
23 | 27 |
|
24 | 28 | 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}" |
28 | 33 |
|
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') |
31 | 36 |
|
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}" |
34 | 40 |
|
35 | 41 |
|
36 | 42 | def test_mapswipe_workers_service_account(): |
37 | 43 | # 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 |
41 | 48 |
|
42 | 49 |
|
43 | 50 | 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 |
47 | 55 |
|
48 | | - with open(file_path, 'r') as f: |
| 56 | + with open(file_path, "r") as f: |
49 | 57 | configuration = json.load(f) |
50 | 58 |
|
51 | 59 | # 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}" |
54 | 63 |
|
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}" |
57 | 67 |
|
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}" |
60 | 71 |
|
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}" |
63 | 75 |
|
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}" |
66 | 79 |
|
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}" |
69 | 83 |
|
70 | 84 | # 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}" |
73 | 88 |
|
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}" |
76 | 92 |
|
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}" |
79 | 96 |
|
80 | 97 | # 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}" |
83 | 101 |
|
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}" |
86 | 105 |
|
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}" |
89 | 109 |
|
90 | 110 | # 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}" |
93 | 114 |
|
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}" |
96 | 118 |
|
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}" |
99 | 122 |
|
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}" |
102 | 126 |
|
103 | 127 | # 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}" |
106 | 131 |
|
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}" |
109 | 135 |
|
110 | 136 | # 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}" |
113 | 140 |
|
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}" |
116 | 144 |
|
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}" |
119 | 148 |
|
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}" |
122 | 152 |
|
123 | 153 |
|
124 | 154 | 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 |
128 | 159 |
|
129 | | - with open(file_path, 'r') as f: |
| 160 | + with open(file_path, "r") as f: |
130 | 161 | app_config = f.read() |
131 | 162 |
|
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}" |
134 | 166 |
|
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}" |
137 | 170 |
|
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}" |
140 | 174 |
|
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 | + ) |
143 | 179 |
|
144 | 180 |
|
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__": |
181 | 182 | test_firebase_config() |
182 | 183 | test_postgres_config() |
183 | 184 | test_mapswipe_workers_service_account() |
184 | 185 | test_mapswipe_workers_configuration() |
185 | 186 | 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