Skip to content

Commit

Permalink
Merge pull request #5 from Kalkuli/81_configurar_ambiente_de_testes
Browse files Browse the repository at this point in the history
Solve 81 Configurar Ambiente de Testes
  • Loading branch information
MarianaPicolo authored Sep 24, 2018
2 parents 0af3553 + a519ea4 commit 5a5867f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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```
30 changes: 28 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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()
cli()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Pillow
pytesseract
opencv-python
Flask-Testing==0.6.2
coverage==4.5.1

0 comments on commit 5a5867f

Please sign in to comment.