From ea9e611d53788a8cf9b2b373df61854cad1f0f96 Mon Sep 17 00:00:00 2001 From: Bernardo Henrique Date: Thu, 20 Sep 2018 17:48:55 -0300 Subject: [PATCH 1/3] Adds Continous Integration Adds tavis file which runs all tests and projs builds. Adds Build Flag. --- .travis.yml | 16 ++++++++++++++++ README.md | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..dde723d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +sudo: required +services: + - docker +env: + DOCKER_COMPOSE_VERSION: 1.21.1 +before_install: + - sudo rm /usr/local/bin/docker-compose + - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + - chmod +x docker-compose + - sudo mv docker-compose /usr/local/bin +before_script: + - docker-compose -f docker-compose-dev.yml up --build -d +script: + - docker-compose -f docker-compose-dev.yml run base python manage.py test +after_script: + - docker-compose -f docker-compose-dev.yml down \ No newline at end of file diff --git a/README.md b/README.md index c7db08d..a5bb79e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Build Status](https://travis-ci.org/Kalkuli/2018.2-Kalkuli_Interpretation.svg?branch=master +)](https://travis-ci.com/Kalkuli/2018.2-Kalkuli_Interpretation) + # 2018.2-Kalkuli_Extraction Microsserviço para a extração de texto de notas fiscais escaneadas. From c17b248b52006f9c3f7c7946d6ada56b04abd697 Mon Sep 17 00:00:00 2001 From: Felipe Hargreaves Date: Thu, 20 Sep 2018 23:15:42 -0300 Subject: [PATCH 2/3] Add tests coverage. --- manage.py | 30 ++++++++++++++++++++++++++++-- requirements.txt | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/manage.py b/manage.py index a1f4c8e..aa035cc 100644 --- a/manage.py +++ b/manage.py @@ -1,6 +1,17 @@ from flask.cli import FlaskGroup from project import app -import unittest +import unittest +import coverage + +COV = coverage.coverage( + branch=True, + include='project/*', + omit=[ + 'project/tests/*', + 'project/config.py', + ] +) +COV.start() cli = FlaskGroup(app) @@ -15,6 +26,21 @@ def test(): return 1 +@cli.command() +def cov(): + """Runs the unit tests with coverage.""" + tests = unittest.TestLoader().discover('project/tests') + result = unittest.TextTestRunner(verbosity=2).run(tests) + if result.wasSuccessful(): + COV.stop() + COV.save() + print('Coverage Summary:') + COV.report() + COV.html_report() + COV.erase() + return 0 + return 1 + if __name__ == '__main__': - cli() \ No newline at end of file + cli() diff --git a/requirements.txt b/requirements.txt index bf29e38..175f64c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ Pillow pytesseract opencv-python Flask-Testing==0.6.2 +coverage==4.5.1 \ No newline at end of file From a519ea43ede6469bdbf8fa2a75874259564d0375 Mon Sep 17 00:00:00 2001 From: Bernardo Henrique Date: Thu, 20 Sep 2018 23:59:33 -0300 Subject: [PATCH 3/3] Hotfix --- .travis.yml | 2 +- README.md | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index dde723d..2532592 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,6 @@ before_install: before_script: - docker-compose -f docker-compose-dev.yml up --build -d script: - - docker-compose -f docker-compose-dev.yml run base python manage.py test + - docker-compose -f docker-compose-dev.yml run base python3.6 manage.py test after_script: - docker-compose -f docker-compose-dev.yml down \ No newline at end of file diff --git a/README.md b/README.md index a5bb79e..7a4afb0 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,16 @@ Microsserviço para a extração de texto de notas fiscais escaneadas. As rotas estarão disponíveis através de localhost:5001 -## Testes +## Testando - ```docker-compose -f docker-compose-dev.yml run base python3.6 manage.py test``` +Para rodar os testes utilize o comando: + +```docker-compose -f docker-compose-dev.yml run base python3.6 manage.py test``` + +E para saber a cobertura dos testes utilize: + +```docker-compose -f docker-compose-dev.yml run base python3.6 manage.py cov``` + +Para acessar a visualização do HTML coverage no browser, acesse a pasta htmlcov e abra o arquivo index.html no navegador, ou utilize o comando: + +```google-chrome ./htmlcov/index.html``` \ No newline at end of file