summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPyry Heiskanen <pyry.heiskanen@gmail.com>2019-04-06 15:12:14 +0300
committerPyry Heiskanen <pyry.heiskanen@gmail.com>2019-04-06 15:12:14 +0300
commitab9c02fd365dde7c4f26ff57898410504e03b895 (patch)
treed09136f905b1ac54d5660e290537a1cb81e35b53
parenta3a95bc0c1a290ae944e01baceb6a2380e1693b6 (diff)
downloadickapi-ab9c02fd365dde7c4f26ff57898410504e03b895.tar.gz
Implement apitest with aiohttp-pytestpyry/apitest
-rw-r--r--Makefile9
-rw-r--r--apitest/test_version.py13
-rw-r--r--apitest/version.py22
-rw-r--r--gunicorn.conf2
-rw-r--r--setup.py6
5 files changed, 24 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index e7ec035..1aa1e36 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,12 @@ lint:
pycodestyle ickapi
pylint -j0 -d missing-docstring ickapi
-test: lint
+apitest:
+ gunicorn --config gunicorn.conf ickapi.main:app > /dev/null 2>&1 &
+ pytest --rootdir=apitest || true
+ pkill -F ickapi.pid
+
+test: lint apitest
run:
gunicorn --config gunicorn.conf --reload ickapi.main:app
@@ -25,4 +30,4 @@ clean:
reset: clean
rm -rf env/
-.PHONY: all env lint test run clean reset
+.PHONY: all env lint apitest test run clean reset
diff --git a/apitest/test_version.py b/apitest/test_version.py
new file mode 100644
index 0000000..1d72cd8
--- /dev/null
+++ b/apitest/test_version.py
@@ -0,0 +1,13 @@
+"""Version endpoint test module.
+"""
+
+import aiohttp
+
+
+async def test_version():
+ """Test version endpoint"""
+ async with aiohttp.ClientSession() as session:
+ async with session.get('http://0.0.0.0:8080/version') as resp:
+ assert resp.status == 200
+ resp = await resp.json()
+ assert 'api' in resp.keys()
diff --git a/apitest/version.py b/apitest/version.py
deleted file mode 100644
index 79183f4..0000000
--- a/apitest/version.py
+++ /dev/null
@@ -1,22 +0,0 @@
-"""Version endpoint test module.
-"""
-
-import asyncio
-
-import aiohttp
-
-
-async def main(url):
- """Test version endpoint"""
- async with aiohttp.ClientSession() as session:
- async with session.get(url) as resp:
- assert resp.status == 200
- resp = await resp.json()
- assert 'api' in resp.keys()
- print("Version test oolrait!")
-
-
-if __name__ == '__main__':
- LOOP = asyncio.get_event_loop()
- LOOP.run_until_complete(main('http://0.0.0.0:8080/version'))
- LOOP.close()
diff --git a/gunicorn.conf b/gunicorn.conf
index 81c8aa1..52acf44 100644
--- a/gunicorn.conf
+++ b/gunicorn.conf
@@ -4,4 +4,4 @@ worker_class = 'aiohttp.worker.GunicornWebWorker'
errorlog = '-'
accesslog = '-'
loglevel = 'info'
-pidfile = '/tmp/ickapi.pid'
+pidfile = 'ickapi.pid'
diff --git a/setup.py b/setup.py
index 30bf11c..c5f402f 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,6 @@
import setuptools
-
with open('ickapi/version.py', 'r') as f:
exec(f.read())
@@ -31,12 +30,13 @@ setuptools.setup(
'pydocstyle',
'pylint',
'pytest',
+ 'pytest-aiohttp',
]
},
classifiers=[
'Development Status :: 3 - Alpha',
- 'License :: OSI Approved :: '
- + 'GNU General Public License v3 or later (GPLv3+)',
+ 'License :: OSI Approved :: ' +
+ 'GNU General Public License v3 or later (GPLv3+)',
'Environment :: Web Environment',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',