added tests

This commit is contained in:
wangobango 2021-11-30 16:13:45 +01:00
parent 7f26747f09
commit 5cdabb14eb
8 changed files with 61 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
__pycache__/*
venv/*
*.egg-info
__pycache__
.pytest_cache

View File

@ -9,4 +9,4 @@ RUN bash setup_core.sh
RUN pip3 install -r requirements.txt
EXPOSE 5000/udp
EXPOSE 5000/tcp
CMD ["python3", "app.py"]
CMD ["python3", "ayct-backend/app.py"]

0
ayct-backend/__init__.py Normal file
View File

View File

@ -12,6 +12,9 @@ class Hello(Resource):
api.add_resource(Hello, "/hello")
def create_app():
return app
if __name__ == "__main__":
port = int(os.environ.get('PORT', 5000))
app.run(host = '0.0.0.0', port = port)

View File

@ -0,0 +1,20 @@
import os
import tempfile
import pytest
from app import create_app
@pytest.fixture
def client():
app = create_app()
app.run(host = '0.0.0.0', port = 5000)
with app.test_client() as client:
with app.app_context():
pass
yield client
def test_first_endpoint(client):
rv = client.get("/hello")
assert b'All You Can Tweet' in rv.data

7
pyproject.toml Normal file
View File

@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"flask"
]
build-backend = "setuptools.build_meta"

View File

@ -1,2 +1,3 @@
Flask==2.0.2
Flask-RESTful==0.3.9
flask_restful==0.3.9
pytest==6.2.5

24
setup.cfg Normal file
View File

@ -0,0 +1,24 @@
[metadata]
name = pbrAyctBackend
version = 0.0.1
author = Łukasz Ramon Piotrek
author_email = ramon.dyzman@gmail.com
description = A small example package
long_description = file: readme.md
long_description_content_type = text/markdown
url = https://git.wmi.amu.edu.pl/s434708/pbr-ayct-backend
project_urls =
Bug Tracker = https://github.com/pypa/sampleproject/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent
[options]
package_dir =
= ayct-backend
packages = find:
python_requires = >=3.6
[options.packages.find]
where = src