Skip to content

simple unit & component tests #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions rest/rest/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
# }
#},
}


Expand Down
1 change: 0 additions & 1 deletion rest/rest_api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pip._internal.cli.cmdoptions import list_exclude
from rest_framework import serializers

from .models import Document
Expand Down
Empty file added rest/rest_api/test/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions rest/rest_api/test/test_db_access.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions rest/rest_api/test/test_hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pytest


@pytest.mark.unit
def test_hello_world():
assert 'hello_world' == 'hello_world'
1 change: 1 addition & 0 deletions rest/rest_api/test/test_rest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#todo
19 changes: 19 additions & 0 deletions rest/rest_api/test/test_serializer.py
Original file line number Diff line number Diff line change
@@ -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