Skip to content

Commit 020bc23

Browse files
committed
tests: make sure access to default can also be blocked
1 parent bcefbe8 commit 020bc23

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

pytest_django_test/settings_mysql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"TEST": {
4646
"CHARSET": "utf8mb4",
4747
"COLLATION": "utf8mb4_unicode_ci",
48+
"DEPENDENCIES": [],
4849
},
4950
},
5051
}

pytest_django_test/settings_postgres.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@
2727
"USER": environ.get("TEST_DB_USER", ""),
2828
"PASSWORD": environ.get("TEST_DB_PASSWORD", ""),
2929
"HOST": environ.get("TEST_DB_HOST", ""),
30+
"TEST": {
31+
"DEPENDENCIES": [],
32+
},
3033
},
3134
}

pytest_django_test/settings_sqlite.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@
1616
"second": {
1717
"ENGINE": "django.db.backends.sqlite3",
1818
"NAME": ":memory:",
19+
"TEST": {
20+
"DEPENDENCIES": [],
21+
},
1922
},
2023
}

pytest_django_test/settings_sqlite_file.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"NAME": "/pytest_django_tests_second",
3333
"TEST": {
3434
"NAME": _filename_second,
35+
"DEPENDENCIES": [],
3536
},
3637
},
3738
}

tests/test_database.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ def test_not_allowed_database(self) -> None:
325325
with pytest.raises(AssertionError, match="not allowed"):
326326
SecondItem.objects.create(name="spam")
327327

328+
@pytest.mark.django_db(databases=["second"])
329+
def test_not_allowed_database_non_default(self) -> None:
330+
with pytest.raises(AssertionError, match="not allowed"):
331+
Item.objects.create(name="spam")
332+
328333
@pytest.mark.django_db(databases=["replica"])
329334
def test_replica_database(self) -> None:
330335
Item.objects.using("replica").count()

0 commit comments

Comments
 (0)