[tests] Ensure it is ok the enter the same name twice
This commit is contained in:
parent
819bbfc7d9
commit
f1ab7afb6f
1 changed files with 18 additions and 1 deletions
|
@ -5,8 +5,9 @@ from hypothesis import given, strategies as st
|
|||
|
||||
from .models import Teil
|
||||
|
||||
names = st.text(alphabet=st.characters(exclude_categories=["C"]), min_size=1)
|
||||
|
||||
@given(data=st.text(alphabet=st.characters(exclude_categories=["C"])))
|
||||
@given(data=names)
|
||||
def test_submitted_data_ends_up_in_database(data, session: Client):
|
||||
|
||||
with pytest.raises(Teil.DoesNotExist):
|
||||
|
@ -16,3 +17,19 @@ def test_submitted_data_ends_up_in_database(data, session: Client):
|
|||
|
||||
assert response.status_code == 302
|
||||
assert Teil.objects.get(name=data)
|
||||
|
||||
|
||||
@given(data=names)
|
||||
def test_entering_same_name_twice_does_not_change_database_entry(data, session: Client):
|
||||
assert not Teil.objects.filter(name=data).exists()
|
||||
|
||||
response = session.post(reverse("collector:enter"), data={"new_name": data})
|
||||
assert response.status_code == 302
|
||||
|
||||
assert Teil.objects.filter(name=data).count() == 1
|
||||
|
||||
response = session.post(reverse("collector:enter"), data={"new_name": data})
|
||||
assert response.status_code == 302
|
||||
|
||||
assert Teil.objects.filter(name=data).count() == 1
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue