Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from fecgov/feature/8-code-coverage
Browse files Browse the repository at this point in the history
Added first unit test to verify code coverage
  • Loading branch information
mjtravers authored Feb 14, 2022
2 parents 41763dd + 00e8914 commit 0d46489
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
10 changes: 1 addition & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,7 @@ jobs:
- run:
name: Run tests, save a coverage report, and save coverage percentage
command: |
pytest --cov=. --cov-report=xml --cov-report=html --cov-report=term || EXIT_CODE=$?
if [ $EXIT_CODE == "0" ]; then
echo "Tests ran successfully"
elif [ $EXIT_CODE == "5" ]; then
echo "No tests found. Continuing."
else
echo "Unit test errors. pytest exited with $EXIT_CODE."
exit 1
fi
PYTHONPATH=. pytest --cov=. --cov-report=xml --cov-report=html --cov-report=term
- store_artifacts:
path: htmlcov
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ certifi==2018.10.15
chardet==3.0.4
Click==7.0
cx-Oracle==7.0.0
Flask==1.0.2
Flask==2.0.2
Flask-Cors==3.0.9
Flask-HTTPAuth==3.2.4
idna==2.7
Expand All @@ -21,7 +21,7 @@ ipdb==0.12.3
pypdftk==0.4
boto3==1.14.60
botocore==1.17.60
Flask-API==1.1
Flask-API==3.0.post1
PyPDF2==1.26.0
pdfkit==0.6.1
beautifulsoup4==4.7.1
Expand Down
5 changes: 1 addition & 4 deletions routes/src/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

def log_init():
formatter = jsonlogger.JsonFormatter(
'{"timestamp":%(asctime),"message":%(message),'
'"function_name":%(funcName),"logger_name":%(name),'
'"logger_level":%(levelname),"filename":%(filename),'
'"line_number":%(lineno)'
'%(timestamp)s %(messages)s %(funcName)s %(name)s %(levelname)s %(filename)s %(lineno)s'
)

logHandler = logging.StreamHandler(sys.stdout)
Expand Down
Empty file added routes/src/tests/conftest.py
Empty file.
12 changes: 12 additions & 0 deletions routes/src/tests/test_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from unittest import TestCase
from routes.src.common import get_return_envelope

class TestCommon(TestCase):

def test_get_return_envelope(self):
msg = "Test message 1"
data = [1,2,3]
envelope = get_return_envelope(success=True, message=msg, data=data)
self.assertTrue(envelope['success'])
self.assertEqual(msg, envelope['message'])
self.assertEqual(data, envelope['results'])

0 comments on commit 0d46489

Please sign in to comment.