summaryrefslogtreecommitdiff
path: root/tests/check_framework/test_async_checks.py
blob: a054503ca88af54ca6658c03c5411510fe92e08d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import os
from unittest import mock

from django.core.checks.async_checks import E001, check_async_unsafe
from django.test import SimpleTestCase


class AsyncCheckTests(SimpleTestCase):
    @mock.patch.dict(os.environ, {"DJANGO_ALLOW_ASYNC_UNSAFE": ""})
    def test_no_allowed_async_unsafe(self):
        self.assertEqual(check_async_unsafe(None), [])

    @mock.patch.dict(os.environ, {"DJANGO_ALLOW_ASYNC_UNSAFE": "true"})
    def test_allowed_async_unsafe_set(self):
        self.assertEqual(check_async_unsafe(None), [E001])