Add unit test.
This commit is contained in:
parent
77ed0feebd
commit
a6fce02c56
3 changed files with 47 additions and 3 deletions
9
.github/workflows/build.yaml
vendored
9
.github/workflows/build.yaml
vendored
|
@ -19,14 +19,17 @@ jobs:
|
|||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flake8 pytest
|
||||
pip install flake8 unittest
|
||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
- name: Install bapsicle as module
|
||||
run: |
|
||||
pip install -e .
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||
- name: Test with pytest
|
||||
- name: Test with unittest
|
||||
run: |
|
||||
pytest
|
||||
python -m unittest
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
41
tests/test_ui.py
Normal file
41
tests/test_ui.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
from bapsicle import server
|
||||
import unittest
|
||||
|
||||
|
||||
class TestUI(unittest.TestCase):
|
||||
|
||||
# initialization logic for the test suite declared in the test module
|
||||
# code that is executed before all tests in one test run
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
pass
|
||||
|
||||
# clean up logic for the test suite declared in the test module
|
||||
# code that is executed after all tests in one test run
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
pass
|
||||
|
||||
# initialization logic
|
||||
# code that is executed before each test
|
||||
def setUp(self):
|
||||
self.app = server.app.test_client()
|
||||
self.app.testing = True
|
||||
|
||||
# clean up logic
|
||||
# code that is executed after each test
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_index_status_code(self):
|
||||
# sends HTTP GET request to the application
|
||||
# on the specified path
|
||||
result = self.app.get('/')
|
||||
|
||||
# assert the status code of the response
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
|
||||
# runs the unit tests in the module
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in a new issue