Skip to content

Commit 647ee39

Browse files
authored
Merge pull request #48 from mekanix/feature/fix-models
Fix tests
2 parents f25086d + a57a14e commit 647ee39

File tree

6 files changed

+28
-23
lines changed

6 files changed

+28
-23
lines changed

bin/test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set -e
66
export BIN_DIR=`dirname $0`
77
export PROJECT_ROOT="${BIN_DIR}/.."
88
export FLASK_ENV="testing"
9+
export DBTYPE="all"
910

1011
. ${BIN_DIR}/common.sh
1112
setup
@@ -26,4 +27,9 @@ cd "${PROJECT_ROOT}"
2627
rm -rf `find . -name __pycache__`
2728
rm -rf .pytest_cache
2829
flake8 .
30+
31+
export DBTYPE="sql"
2932
py.test --ignore=freenit/project/ --cov=freenit --cov-report=term-missing:skip-covered --cov-report=xml
33+
34+
# export DBTYPE="mongo"
35+
# py.test --ignore=freenit/project/ --cov=freenit --cov-report=term-missing:skip-covered --cov-report=xml

common_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Config:
2222
OPENAPI_REDOC_PATH = '/redoc'
2323
OPENAPI_SWAGGER_UI_PATH = '/swaggerui'
2424
OPENAPI_SWAGGER_UI_URL = '/static/swaggerui/'
25-
OPENAPI_VERSION = '2.0.0'
25+
OPENAPI_VERSION = '3.0.3'
2626
MEDIA_URL = '/media'
2727
MEDIA_PATH = 'media'
2828
ACCOUNT_REQUEST_EXPIRY = 24 # in hours

freenit/models/mongo/__init__.py

Whitespace-only changes.

freenit/models/sql/__init__.py

Whitespace-only changes.

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66

77
PROJECT_ROOT = pathlib.Path(__file__).parent
88
README = (PROJECT_ROOT / 'README.md').read_text()
9-
sql = ['peewee-migrate>=1.1.6']
9+
sql = [
10+
'peewee',
11+
'peewee-migrate>=1.1.6',
12+
]
1013
mongo = ['flask-mongoengine']
1114

1215
setup(
1316
name='freenit',
14-
version='0.1.0',
17+
version='0.1.1',
1518
description='REST API framework based on Flask-Smorest',
1619
long_description=README,
1720
long_description_content_type='text/markdown',

tests/conftest.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import os
22

3-
import pytest
4-
from pytest_factoryboy import register
5-
6-
from config import configs
73
from freenit import create_app
84
from peewee_migrate import Router
95
from peewee_migrate.router import DEFAULT_MIGRATE_DIR
6+
from pytest_factoryboy import register
7+
8+
import pytest
9+
from config import configs
1010

1111
from .factories import AdminFactory, RoleFactory, UserFactory
1212

@@ -17,21 +17,17 @@
1717

1818
@pytest.fixture
1919
def app():
20+
dbtype = os.environ['DBTYPE']
2021
config = configs['testing']
21-
flask_app = create_app(config)
22-
router = Router(
23-
flask_app.db.database,
24-
migrate_dir=f'{DEFAULT_MIGRATE_DIR}/main',
25-
)
26-
# log_router = Router(
27-
# flask_app.logdb.database,
28-
# migrate_dir=f'{DEFAULT_MIGRATE_DIR}/logs',
29-
# )
30-
router.run()
31-
# log_router.run()
22+
flask_app = create_app(config, dbtype=dbtype)
23+
if dbtype == 'sql':
24+
router = Router(
25+
flask_app.db.database,
26+
migrate_dir=f'{DEFAULT_MIGRATE_DIR}/main',
27+
)
28+
router.run()
3229
yield flask_app
33-
flask_app.db.close_db('')
34-
# flask_app.logdb.close_db('')
35-
current_path = os.path.dirname(__file__)
36-
os.remove('{}/../test.db'.format(current_path))
37-
# os.remove('{}/../log_test.db'.format(current_path))
30+
if dbtype == 'sql':
31+
flask_app.db.close_db('')
32+
current_path = os.path.dirname(__file__)
33+
os.remove('{}/../test.db'.format(current_path))

0 commit comments

Comments
 (0)