[tests] use hypothesis to generate test data
This commit is contained in:
parent
1f100d329b
commit
819bbfc7d9
3 changed files with 10 additions and 6 deletions
|
|
@ -1,18 +1,18 @@
|
||||||
from django.urls import reverse
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from django.test import Client
|
from django.test import Client
|
||||||
|
from django.urls import reverse
|
||||||
|
from hypothesis import given, strategies as st
|
||||||
|
|
||||||
from .models import Teil
|
from .models import Teil
|
||||||
|
|
||||||
|
|
||||||
def test_submitted_data_ends_up_in_database(client: Client):
|
@given(data=st.text(alphabet=st.characters(exclude_categories=["C"])))
|
||||||
data = "Test Diode 0815 grün"
|
def test_submitted_data_ends_up_in_database(data, session: Client):
|
||||||
|
|
||||||
with pytest.raises(Teil.DoesNotExist):
|
with pytest.raises(Teil.DoesNotExist):
|
||||||
Teil.objects.get(name=data)
|
Teil.objects.get(name=data)
|
||||||
|
|
||||||
response = client.post(reverse("collector:enter"), data={"new_name": data})
|
response = session.post(reverse("collector:enter"), data={"new_name": data})
|
||||||
|
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
assert Teil.objects.get(name=data)
|
assert Teil.objects.get(name=data)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
django-extensions
|
django-extensions
|
||||||
django-stubs
|
django-stubs
|
||||||
|
hypothesis[django]
|
||||||
ipython
|
ipython
|
||||||
pip-compile-multi
|
pip-compile-multi
|
||||||
pytest
|
pytest
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# SHA1:8c7b1dcee98fe0d76082d6a9af130adb2b2c5c9b
|
# SHA1:d0cece8f6bf419b959d3618afd4e5760e5a40a9a
|
||||||
#
|
#
|
||||||
# This file is autogenerated by pip-compile-multi
|
# This file is autogenerated by pip-compile-multi
|
||||||
# To update, run:
|
# To update, run:
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#
|
#
|
||||||
-r base.txt
|
-r base.txt
|
||||||
asttokens==3.0.0
|
asttokens==3.0.0
|
||||||
|
attrs==25.3.0
|
||||||
build==1.2.2.post1
|
build==1.2.2.post1
|
||||||
click==8.1.8
|
click==8.1.8
|
||||||
decorator==5.2.1
|
decorator==5.2.1
|
||||||
|
|
@ -14,6 +15,7 @@ django-extensions==3.2.3
|
||||||
django-stubs==5.1.3
|
django-stubs==5.1.3
|
||||||
django-stubs-ext==5.1.3
|
django-stubs-ext==5.1.3
|
||||||
executing==2.2.0
|
executing==2.2.0
|
||||||
|
hypothesis==6.129.0
|
||||||
iniconfig==2.0.0
|
iniconfig==2.0.0
|
||||||
ipython==9.0.2
|
ipython==9.0.2
|
||||||
ipython-pygments-lexers==1.1.1
|
ipython-pygments-lexers==1.1.1
|
||||||
|
|
@ -35,6 +37,7 @@ pytest==8.3.5
|
||||||
pytest-django==4.10.0
|
pytest-django==4.10.0
|
||||||
ruff==0.9.10
|
ruff==0.9.10
|
||||||
setuptools==76.0.0
|
setuptools==76.0.0
|
||||||
|
sortedcontainers==2.4.0
|
||||||
stack-data==0.6.3
|
stack-data==0.6.3
|
||||||
toposort==1.10
|
toposort==1.10
|
||||||
traitlets==5.14.3
|
traitlets==5.14.3
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue