diff --git a/rest/rest/settings.py b/rest/rest/settings.py index 14ed63e..d8b0201 100644 --- a/rest/rest/settings.py +++ b/rest/rest/settings.py @@ -87,10 +87,21 @@ 'options': '-c search_path=archive,public' } }, - 'sqlite': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', - } + #'sqlite': { + # 'ENGINE': 'django.db.backends.sqlite3', + # 'NAME': BASE_DIR / 'db.sqlite3', + #}, + #'TEST': { + # 'ENGINE': 'django.db.backends.postgresql_psycopg2', + # 'NAME': 'postgres', + # 'USER': 'postgres', + # 'PASSWORD': 'geheim', + # 'HOST': '127.0.0.1', + # 'PORT': '6543', + # 'OPTIONS': { # set schema + # 'options': '-c search_path=archive,public' + # } + #}, } diff --git a/rest/rest_api/serializers.py b/rest/rest_api/serializers.py index a188aba..d33c9ca 100644 --- a/rest/rest_api/serializers.py +++ b/rest/rest_api/serializers.py @@ -1,4 +1,3 @@ -from pip._internal.cli.cmdoptions import list_exclude from rest_framework import serializers from .models import Document diff --git a/rest/rest_api/test/__init__.py b/rest/rest_api/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rest/rest_api/test/test_db_access.py b/rest/rest_api/test/test_db_access.py new file mode 100644 index 0000000..e18226c --- /dev/null +++ b/rest/rest_api/test/test_db_access.py @@ -0,0 +1,10 @@ +import pytest + +from rest_api.models import Document + + +# testsuite creates own test-database +@pytest.mark.django_db(databases=['default']) +def test_get_all_docs(client): + documents = Document.objects.all() + assert documents.count() == 0 diff --git a/rest/rest_api/test/test_hello_world.py b/rest/rest_api/test/test_hello_world.py new file mode 100644 index 0000000..f02dbfc --- /dev/null +++ b/rest/rest_api/test/test_hello_world.py @@ -0,0 +1,6 @@ +import pytest + + +@pytest.mark.unit +def test_hello_world(): + assert 'hello_world' == 'hello_world' diff --git a/rest/rest_api/test/test_rest.py b/rest/rest_api/test/test_rest.py new file mode 100644 index 0000000..8b68f79 --- /dev/null +++ b/rest/rest_api/test/test_rest.py @@ -0,0 +1 @@ +#todo \ No newline at end of file diff --git a/rest/rest_api/test/test_serializer.py b/rest/rest_api/test/test_serializer.py new file mode 100644 index 0000000..75deab5 --- /dev/null +++ b/rest/rest_api/test/test_serializer.py @@ -0,0 +1,19 @@ +import pytest + +from rest_api.serializers import DocumentSerializer + + +@pytest.mark.unit +def test_valid_model(): + document_serializer = DocumentSerializer(data={"title": "pytest", + "person": "python3", + "file_size": -2048}) + assert document_serializer.is_valid() == True + + +@pytest.mark.unit +def test_invalid_model(): + document_serializer = DocumentSerializer(data={"title": "pytest", + "person": 204, + "file_size": "fake number"}) + assert document_serializer.is_valid() == False