@@ -216,6 +216,37 @@ def test_full_db_check_error(mocker, app, db, client):
216
216
assert json .loads (response .data .decode ())["status" ] == "error"
217
217
218
218
219
+ def test_full_migrate_check (mocker , client , app , db , migrate ):
220
+ mocker .patch (
221
+ "alembic.script.ScriptDirectory.get_heads" , return_value = ("17164a7d1c2e" ,)
222
+ )
223
+ mocker .patch (
224
+ "alembic.migration.MigrationContext.get_current_heads" ,
225
+ return_value = ("17164a7d1c2e" ,),
226
+ )
227
+ Dockerflow (app , migrate = migrate )
228
+ with app .app_context ():
229
+ assert "check_migrations_applied" in checks .get_checks ()
230
+ response = client .get ("/__heartbeat__" )
231
+ assert response .status_code == 200
232
+ assert json .loads (response .data .decode ())["status" ] == "ok"
233
+
234
+
235
+ def test_full_migrate_check_error (mocker , client , app , db , migrate ):
236
+
237
+ with app .app_context ():
238
+ mocker .patch .object (db .engine , "connect" , side_effect = SQLAlchemyError )
239
+ Dockerflow (app , migrate = migrate )
240
+ assert "check_migrations_applied" in checks .get_checks ()
241
+ response = client .get ("/__heartbeat__" )
242
+ assert response .status_code == 200
243
+ assert response .json ["status" ] == "info"
244
+ assert (
245
+ health .INFO_CANT_CHECK_MIGRATIONS
246
+ in response .json ["details" ]["check_migrations_applied" ]["messages" ]
247
+ )
248
+
249
+
219
250
def assert_log_record (record , errno = 0 , level = logging .INFO ):
220
251
assert record .levelno == level
221
252
assert record .errno == errno
0 commit comments