Skip to content

Commit

Permalink
Merge pull request geocoders#20 from amatissart/allure
Browse files Browse the repository at this point in the history
WIP: Allure integration
  • Loading branch information
antoine-de authored May 23, 2018
2 parents ddc94ab + c2e5d59 commit ed2c62f
Show file tree
Hide file tree
Showing 7 changed files with 360 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
__pycache__
*.pyc
reports/*

allure/res*
allure/allure-report/
21 changes: 21 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[[source]]

name = "pypi"
url = "https://pypi.python.org/simple"
verify_ssl = true


[packages]

pytest = "*"
requests = "*"
pyaml = "*"
geopy = "*"
unidecode = "*"
allure-pytest = "*"
invoke = "*"


[dev-packages]

ipython = "*"
286 changes: 286 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,20 @@ has the subkeys you want to test against (`name`, `housenumber`…).
Optional keys: `limit`, `lang`, `lat` and `lon`, `skip`.
You can add categories to your test by using the key `mark` (which expects a
list), that you can then run with `-m yourmarker`.

## Generate Allure report

* Install geocoder-tester with pipenv and open a shell in the virtualenv

```bash
pipenv install
pipenv shell
```

* Run some tests via invoke

```bash
INVOKE_API_URL=http://example.com/autocomplete INVOKE_TESTS_FILES=geocoder_tester/world/france/test_poi.csv invoke -r allure
```

* Allure report is generated in `allure/allure-report`
Empty file added allure/allure-report/.keep
Empty file.
2 changes: 2 additions & 0 deletions allure/invoke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
api_url:
tests_files:
31 changes: 31 additions & 0 deletions allure/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from datetime import datetime
import invoke
from invoke import task
from os import path

@task
def generate_report(ctx, results_dir):
print('Generating Allure report...')
with ctx.cd('allure'):
if path.exists('{}/allure-report/history'.format(ctx.cwd)):
ctx.run('mv allure-report/history {}'.format(results_dir))
ctx.run('allure generate {} --clean'.format(results_dir))


@task(default=True)
def run_tests(ctx):
dt_now = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S')
results_dir = 'res_{}'.format(dt_now)

ctx.run("""
pytest {tests_files} --api-url {api_url} \
--loose-compare --tb=short --alluredir allure/{results_dir}
""".format(
tests_files=ctx.tests_files,
api_url=ctx.api_url,
results_dir=results_dir
),
warn=True
)

generate_report(ctx, results_dir)

0 comments on commit ed2c62f

Please sign in to comment.