diff --git a/openlobby/core/tests.py b/openlobby/core/tests.py deleted file mode 100644 index 7ce503c2dd97ba78597f6ff6e4393132753573f6..0000000000000000000000000000000000000000 --- a/openlobby/core/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/tests/snapshots/__init__.py b/openlobby/core/tests/__init__.py similarity index 100% rename from tests/snapshots/__init__.py rename to openlobby/core/tests/__init__.py diff --git a/tests/conftest.py b/openlobby/core/tests/conftest.py similarity index 93% rename from tests/conftest.py rename to openlobby/core/tests/conftest.py index 111f1cf97bf5866adfb09db3d667f17bb67093b7..1eec378b827c681a086d7584830b311e5fee4fbd 100644 --- a/tests/conftest.py +++ b/openlobby/core/tests/conftest.py @@ -5,7 +5,7 @@ import random import string -from openlobby.management import init_alias +from ..management import init_alias @pytest.fixture(scope='session') diff --git a/openlobby/core/tests/snapshots/__init__.py b/openlobby/core/tests/snapshots/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/snapshots/snap_test_management.py b/openlobby/core/tests/snapshots/snap_test_management.py similarity index 100% rename from tests/snapshots/snap_test_management.py rename to openlobby/core/tests/snapshots/snap_test_management.py diff --git a/tests/test_auth.py b/openlobby/core/tests/test_auth.py similarity index 77% rename from tests/test_auth.py rename to openlobby/core/tests/test_auth.py index 51d1e97b109d8dd8c59cd0d1af07bacd0cfbb94f..0659a6691a227f5766a49832865447150e29b552 100644 --- a/tests/test_auth.py +++ b/openlobby/core/tests/test_auth.py @@ -1,14 +1,9 @@ +from django.conf import settings import time import jwt import pytest -from openlobby.settings import ( - SECRET_KEY, - JWT_ALGORITHM, - LOGIN_ATTEMPT_EXPIRATION, - SESSION_EXPIRATION, -) -from openlobby.auth import ( +from ..auth import ( get_login_attempt_expiration_time, get_session_expiration_time, create_access_token, @@ -18,13 +13,13 @@ from openlobby.auth import ( def test_get_login_attempt_expiration_time(): expiration = get_login_attempt_expiration_time() - expected = int(time.time() + LOGIN_ATTEMPT_EXPIRATION) + expected = int(time.time() + settings.LOGIN_ATTEMPT_EXPIRATION) assert expected <= expiration <= expected + 1 def test_get_session_expiration_time(): expiration = get_session_expiration_time() - expected = int(time.time() + SESSION_EXPIRATION) + expected = int(time.time() + settings.SESSION_EXPIRATION) assert expected <= expiration <= expected + 1 @@ -32,7 +27,7 @@ def test_create_access_token(): session_id = 'idkfa' expiration = int(time.time() + 10) token = create_access_token(session_id, expiration) - payload = jwt.decode(token, SECRET_KEY, algorithms=[JWT_ALGORITHM]) + payload = jwt.decode(token, settings.SECRET_KEY, algorithms=[settings.JWT_ALGORITHM]) assert isinstance(token, str) assert payload['sub'] == session_id assert payload['exp'] == expiration diff --git a/tests/test_documents.py b/openlobby/core/tests/test_documents.py similarity index 96% rename from tests/test_documents.py rename to openlobby/core/tests/test_documents.py index 630dd9397315d2b85593f57ed34d6d30055c8850..ff823d8639dd4659107e3a61894a7f7f40e0cfea 100644 --- a/tests/test_documents.py +++ b/openlobby/core/tests/test_documents.py @@ -1,6 +1,6 @@ import time -from openlobby.documents import SessionDoc, UserDoc +from ..documents import SessionDoc, UserDoc class TestSessionDoc: diff --git a/tests/test_management.py b/openlobby/core/tests/test_management.py similarity index 97% rename from tests/test_management.py rename to openlobby/core/tests/test_management.py index ef1c7389c373ac633f472920e7105c26ebf90ea3..83c87d0f2a4e1c49a3ae7bb66ca5922aaafe003f 100644 --- a/tests/test_management.py +++ b/openlobby/core/tests/test_management.py @@ -1,6 +1,6 @@ import pytest -from openlobby.management import ( +from ..management import ( AliasAlreadyExistsError, IndexAlreadyExistsError, create_index, @@ -9,7 +9,7 @@ from openlobby.management import ( init_documents, reindex, ) -from openlobby.documents import UserDoc +from ..documents import UserDoc def test_create_index(es, index_name): diff --git a/tests/test_paginator.py b/openlobby/core/tests/test_paginator.py similarity index 97% rename from tests/test_paginator.py rename to openlobby/core/tests/test_paginator.py index 590788fd47051349da10dfd359f0472afa39f254..2e3bac7642b51a509c8b740aae147429ab73baec 100644 --- a/tests/test_paginator.py +++ b/openlobby/core/tests/test_paginator.py @@ -1,6 +1,6 @@ import pytest -from openlobby.paginator import PER_PAGE, encode_cursor, decode_cursor, Paginator +from ..paginator import PER_PAGE, encode_cursor, decode_cursor, Paginator @pytest.mark.parametrize('num, cursor', [ diff --git a/tests/test_sanitizers.py b/openlobby/core/tests/test_sanitizers.py similarity index 92% rename from tests/test_sanitizers.py rename to openlobby/core/tests/test_sanitizers.py index 7ddf1cba7488af01b55a3109fc1577bb4537c4f7..12061a1ea0d8460f81e5a7968e0ccec6c9ef913b 100644 --- a/tests/test_sanitizers.py +++ b/openlobby/core/tests/test_sanitizers.py @@ -1,6 +1,6 @@ import pytest -from openlobby.sanitizers import strip_all_tags, extract_text +from ..sanitizers import strip_all_tags, extract_text @pytest.mark.parametrize('input, text', [ diff --git a/pytest.ini b/pytest.ini index e1b7a4018edbb066d5fde12841ba8022fcdae421..854a7af384b1a0a85b3288df7b656f7d733fe535 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,5 @@ [pytest] +DJANGO_SETTINGS_MODULE = openlobby.settings +python_files = tests.py test_*.py *_tests.py env = SECRET_KEY=justForTests diff --git a/requirements.txt b/requirements.txt index e3636923ccf3dbbd2900b67da9f4dab8bcdad146..e464b92c3a78f0060262c56e0d4cf9302849df78 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ Django>=2,<2.1 graphene>=2.0,<3.0 graphene-django>=2.0,<3.0 elasticsearch-dsl>=5.3.0,<6.0.0 -pytest>=3.2.3,<3.3.0 +pytest>=3.3,<4.0 pytest-django>=3.1.2,<3.2 pytest-env>=0.6.2,<0.7 oic>=0.12.0,<0.13