Skip to content

Commit d2beb3f

Browse files
mkniewallnerbluetech
authored andcommitted
Add test for mirror database
1 parent df0abaa commit d2beb3f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/test_database.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,14 @@ def test_replica_database_not_allowed(self, request) -> None:
249249
with pytest.raises(AssertionError, match='not allowed'):
250250
Item.objects.count()
251251

252+
@pytest.mark.django_db(transaction=True, databases=['default', 'replica'])
253+
def test_replica_mirrors_default_database(self, request) -> None:
254+
Item.objects.create(name='spam')
255+
Item.objects.using('replica').create(name='spam')
256+
257+
assert Item.objects.count() == 2
258+
assert Item.objects.using('replica').count() == 2
259+
252260
@pytest.mark.django_db(databases='__all__')
253261
def test_all_databases(self, request) -> None:
254262
Item.objects.count()

0 commit comments

Comments
 (0)