Skip to content
Snippets Groups Projects
Unverified Commit 4378d229 authored by Andreas Valder's avatar Andreas Valder
Browse files

moved unit tests to own module

parent c1b2ee50
No related branches found
No related tags found
Loading
...@@ -7,7 +7,7 @@ unittest: ...@@ -7,7 +7,7 @@ unittest:
- python3 -V - python3 -V
- uname -a - uname -a
- apt install -y sqlite3 locales-all git python3-flask python3-ldap3 python3-requests python3-lxml python3-icalendar python3-mysql.connector python3-requests python3-coverage - apt install -y sqlite3 locales-all git python3-flask python3-ldap3 python3-requests python3-lxml python3-icalendar python3-mysql.connector python3-requests python3-coverage
- python3 -m coverage run tests.py - python3 -m coverage run runTests.py
- python3 -m coverage report --include "./*" - python3 -m coverage report --include "./*"
- python3 -m coverage report -m --include "./*" > report.txt - python3 -m coverage report -m --include "./*" > report.txt
- python3 -m coverage html --include "./*" - python3 -m coverage html --include "./*"
......
...@@ -15,9 +15,9 @@ Hinweis: diese Variante startet eine lokale Testversion der Website, es sind nic ...@@ -15,9 +15,9 @@ Hinweis: diese Variante startet eine lokale Testversion der Website, es sind nic
Alternativ, insbesondere zum Testen der Zugriffsbeschränkungen: Siehe `nginx.example.conf`. Alternativ, insbesondere zum Testen der Zugriffsbeschränkungen: Siehe `nginx.example.conf`.
### Unittests ### Unittests
Tests können mittels `./tests.py` ausgeführt werden. Tests können mittels `./runTests.py` ausgeführt werden.
Coverage Tests können mittels `rm .coverage; python -m coverage run tests.py; python -m coverage html` ausgeführt werden. Dies erstellt einen Ordner `htmlcov` in dem HTML Output liegt. Coverage Tests können mittels `rm .coverage; python -m coverage run runTests.py; python -m coverage html` ausgeführt werden. Dies erstellt einen Ordner `htmlcov` in dem HTML Output liegt.
### Zum Mitmachen: ### Zum Mitmachen:
1. Repo für den eigenen User forken, dafür den "Fork-Button" auf der Website verwenden 1. Repo für den eigenen User forken, dafür den "Fork-Button" auf der Website verwenden
......
File moved
File moved
#!/usr/bin/env python3
import unittest
import os
import server
def setUp():
server.app.testing = True
def tearDown():
os.unlink(server.app.config['SQLITE_DB'])
if __name__ == '__main__':
setUp()
try:
suite = unittest.defaultTestLoader.discover('./tests/', pattern="*")
unittest.TextTestRunner(verbosity=2, failfast=True).run(suite)
finally:
tearDown()
...@@ -26,7 +26,7 @@ if sys.argv[0].endswith('run.py'): ...@@ -26,7 +26,7 @@ if sys.argv[0].endswith('run.py'):
config['SQLITE_INIT_DATA'] = True config['SQLITE_INIT_DATA'] = True
config['DEBUG'] = True config['DEBUG'] = True
config.from_pyfile('config.py', silent=True) config.from_pyfile('config.py', silent=True)
if sys.argv[0].endswith('tests.py'): if sys.argv[0].endswith('runTests.py'):
print('running in test mode') print('running in test mode')
import tempfile import tempfile
# ensure we always use a clean sqlite db for tests # ensure we always use a clean sqlite db for tests
......
#!/usr/bin/env python3
import os import os
import unittest import unittest
import server
import json import json
import server
import flask import flask
from flask import url_for from flask import url_for
class VideoTestCase(unittest.TestCase): class VideoTestCase(unittest.TestCase):
@classmethod def tearDown(self):
def tearDownClass(cls): pass
os.unlink(server.app.config['SQLITE_DB']) #os.unlink(server.app.config['SQLITE_DB'])
def setUp(self): def setUp(self):
server.app.testing = True server.app.testing = True
...@@ -279,8 +277,3 @@ class VideoTestCase(unittest.TestCase): ...@@ -279,8 +277,3 @@ class VideoTestCase(unittest.TestCase):
self.login(c) self.login(c)
r = self.app.get('/internal/cutprogress') r = self.app.get('/internal/cutprogress')
assert r.status_code == 200 assert r.status_code == 200
if __name__ == '__main__':
unittest.main()
import os
import unittest
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment