File: test_migrations.py

package info (click to toggle)
python-django-health-check 3.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 428 kB
  • sloc: python: 1,886; makefile: 6
file content (29 lines) | stat: -rw-r--r-- 958 bytes parent folder | download
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
from unittest.mock import patch

from django.db.migrations import Migration
from django.test import TestCase

from health_check.contrib.migrations.backends import MigrationsHealthCheck


class MockMigration(Migration): ...


class TestMigrationsHealthCheck(TestCase):
    def test_check_status_work(self):
        with patch(
            "health_check.contrib.migrations.backends.MigrationsHealthCheck.get_migration_plan",
            return_value=[],
        ):
            backend = MigrationsHealthCheck()
            backend.run_check()
            self.assertFalse(backend.errors)

    def test_check_status_raises_error_if_there_are_migrations(self):
        with patch(
            "health_check.contrib.migrations.backends.MigrationsHealthCheck.get_migration_plan",
            return_value=[(MockMigration, False)],
        ):
            backend = MigrationsHealthCheck()
            backend.run_check()
            self.assertTrue(backend.errors)