[tests] Ensure new Teil is entered into the DB

This commit is contained in:
bronsen 2025-03-13 17:45:01 +01:00
parent 8500ebb157
commit 55be0c8370
2 changed files with 23 additions and 0 deletions

5
collector/conftest.py Normal file
View file

@ -0,0 +1,5 @@
import pytest
@pytest.fixture(autouse=True)
def enable_db_access_for_all_tests(db):
pass

18
collector/tests.py Normal file
View file

@ -0,0 +1,18 @@
from django.urls import reverse
import pytest
from django.test import Client
from .models import Teil
def test_submitted_data_ends_up_in_database(client: Client):
data = "Test Diode 0815 grün"
with pytest.raises(Teil.DoesNotExist):
Teil.objects.get(name=data)
response = client.post(reverse("collector:enter"), data={"new_name": data})
assert response.status_code == 302
assert Teil.objects.get(name=data)