Skip to content

Commit 3e1a11a

Browse files
aabharyacodingjoe
andauthored
Remove test model default permissions (#451)
Co-authored-by: Johannes Maron <johannes@maron.family>
1 parent 7b93658 commit 3e1a11a

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Generated by Django 4.2.20 on 2025-03-20 11:10
2+
3+
from django.db import migrations
4+
5+
6+
def remove_test_model_default_permissions(apps, schema_editor):
7+
ContentType = apps.get_model("contenttypes", "ContentType")
8+
Permission = apps.get_model("auth", "Permission")
9+
db_alias = schema_editor.connection.alias
10+
11+
try:
12+
test_model_content_type = ContentType.objects.using(db_alias).get(app_label="db", model="testmodel")
13+
Permission.objects.using(db_alias).filter(content_type=test_model_content_type).delete()
14+
except ContentType.DoesNotExist:
15+
return
16+
17+
18+
class Migration(migrations.Migration):
19+
dependencies = [
20+
("db", "0001_initial"),
21+
]
22+
23+
operations = [
24+
migrations.AlterModelOptions(
25+
name="testmodel",
26+
options={"default_permissions": ()},
27+
),
28+
migrations.RunPython(
29+
code=remove_test_model_default_permissions,
30+
reverse_code=migrations.RunPython.noop,
31+
),
32+
]

health_check/db/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ class TestModel(models.Model):
66

77
class Meta:
88
db_table = "health_check_db_testmodel"
9+
default_permissions = ()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ name = "health_check"
7373
write_to = "health_check/_version.py"
7474

7575
[tool.pytest.ini_options]
76-
addopts = "--nomigrations --cov --reuse-db --strict-markers --cov-report=xml --cov-report=term --doctest-modules"
76+
addopts = "--cov --strict-markers --cov-report=xml --cov-report=term --doctest-modules"
7777
testpaths = [
7878
"tests",
7979
]

0 commit comments

Comments
 (0)