teilchensammler/collector/tests.py

18 lines
442 B
Python

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)