Skip to content

Commit

Permalink
Introducing pytest setup
Browse files Browse the repository at this point in the history
  • Loading branch information
texx00 committed Oct 13, 2020
1 parent edbe977 commit 6caabd1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion UIserver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
app.config['UPLOAD_FOLDER'] = "./UIserver/static/Drawings"
socketio = SocketIO(app)

file_path = os.path.abspath(os.getcwd())+"\database.db"
file_path = os.path.join(os.path.abspath(os.getcwd()), "database.db")
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'+file_path
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
Expand Down
31 changes: 31 additions & 0 deletions UIserver/tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
import tempfile
from flask_sqlalchemy import SQLAlchemy

import pytest

from UIserver import UIserver

# to run tests use "python -m pytest UIserver/tests" in the main project folder
# at the moment there is a deprecation waring related to the "future" library


@pytest.fixture
def client():
db_fd, UIserver.app.config['SQLALCHEMY_DATABASE_URI'] = tempfile.mkstemp()
UIserver.app.config['TESTING'] = True

with UIserver.app.test_client() as client:
with UIserver.app.app_context():
UIserver.db = SQLAlchemy(UIserver.app)
yield client

os.close(db_fd)
os.unlink(UIserver.app.config['SQLALCHEMY_DATABASE_URI'])

def test_empty_database(client):
"""Start with a blank database."""

rv = client.get('/')
assert rv.location == 'http://localhost/preview'
assert rv.default_status == 200
18 changes: 18 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
alembic==1.4.2
astroid==2.4.2
atomicwrites==1.4.0
attrs==20.2.0
certifi==2020.4.5.1
chardet==3.0.4
click==7.1.2
colorama==0.4.3
ecdsa==0.15
Flask==1.1.2
Flask-Migrate==2.5.3
Expand All @@ -11,24 +15,33 @@ Flask-SQLAlchemy==2.4.2
future==0.18.2
htmlmin==0.1.12
idna==2.9
importlib-metadata==2.0.0
iniconfig==1.0.1
iso8601==0.1.12
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.11.2
jsmin==2.2.2
lazy-object-proxy==1.4.3
lesscpy==0.14.0
libsass==0.20.1
Mako==1.1.3
MarkupSafe==1.1.1
mccabe==0.6.1
packaging==20.4
pid==3.0.3
Pillow==7.1.2
pip==20.2.3
pluggy==0.13.1
ply==3.11
psutil==5.7.0
py==1.9.0
pyaes==1.6.1
pylint==2.5.3
pyparsing==2.4.7
pyScss==1.3.7
pyserial==3.4
pytest==6.1.1
python-dateutil==2.8.1
python-dotenv==0.13.0
python-editor==1.0.4
Expand All @@ -40,7 +53,12 @@ serial==0.0.97
setuptools==47.1.1
six==1.15.0
SQLAlchemy==1.3.17
toml==0.10.1
typed-ast==1.4.1
urllib3==1.25.9
webassets==2.0
Werkzeug==1.0.1
wheel==0.34.2
wrapt==1.12.1
xxhash==2.0.0
zipp==3.3.0

0 comments on commit 6caabd1

Please sign in to comment.