diff --git a/.gitignore b/.gitignore index 098c0d3..f6e18d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ __pycache__ *.pyc reports/* + +allure/res* +allure/allure-report/ diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..62ab139 --- /dev/null +++ b/Pipfile @@ -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 = "*" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..f8e6180 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,286 @@ +{ + "_meta": { + "hash": { + "sha256": "2cc633031efdcb4e35e03ac8a8bce243954bf1e91c700f624136b6f0a47408a9" + }, + "host-environment-markers": { + "implementation_name": "cpython", + "implementation_version": "3.5.2", + "os_name": "posix", + "platform_machine": "x86_64", + "platform_python_implementation": "CPython", + "platform_release": "4.13.0-31-generic", + "platform_system": "Linux", + "platform_version": "#34~16.04.1-Ubuntu SMP Fri Jan 19 17:11:01 UTC 2018", + "python_full_version": "3.5.2", + "python_version": "3.5", + "sys_platform": "linux" + }, + "pipfile-spec": 6, + "requires": {}, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.python.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "allure-pytest": { + "hashes": [ + "sha256:2c776fc4d618ef0b1f571ea4a2b6819c59e4438c6d42b8f20ac23ea1fb38202e", + "sha256:deab8907eac932f5a83f55d3b59f2b66dffdd293e399fc05ed25fd1050b86f21" + ], + "version": "==2.3.3b1" + }, + "allure-python-commons": { + "hashes": [ + "sha256:fa861c139c20e78de78fd47b161c33683622bc9538926e7bb22d6f668494b026", + "sha256:5eaf0b8230f0f4abe500defebcd5f160117a9a068704e252305a7c85655a1daf" + ], + "version": "==2.3.3b1" + }, + "attrs": { + "hashes": [ + "sha256:4b90b09eeeb9b88c35bc642cbac057e45a5fd85367b985bd2809c62b7b939265", + "sha256:e0d0eb91441a3b53dab4d9b743eafc1ac44476296a2053b6ca3af0b139faf87b" + ], + "version": "==18.1.0" + }, + "certifi": { + "hashes": [ + "sha256:9fa520c1bacfb634fa7af20a76bcbd3d5fb390481724c597da32c719a7dca4b0", + "sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7" + ], + "version": "==2018.4.16" + }, + "chardet": { + "hashes": [ + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691", + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae" + ], + "version": "==3.0.4" + }, + "geographiclib": { + "hashes": [ + "sha256:635da648fce80a57b81b28875d103dacf7deb12a3f5f7387ba7d39c51e096533" + ], + "version": "==1.49" + }, + "geopy": { + "hashes": [ + "sha256:2947f914c89d665e86b19466cce3600f0d0574a54a17c7ba609058a0ef0b5f24", + "sha256:9df0d61b431c51bcc47e64d16f9517dacfed10875f0dfc36cd8cb87c52fa9547" + ], + "version": "==1.14.0" + }, + "idna": { + "hashes": [ + "sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4", + "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f" + ], + "version": "==2.6" + }, + "invoke": { + "hashes": [ + "sha256:621b6564f992c37166e16090d7e7cccb3b922e03a58e980dfa5e543a931b652f", + "sha256:4a4cc031db311cbfb3fdd8ec93a06c892533c27b931f4be14b24c97cd042b14e", + "sha256:21274204515dca62206470b088bbcf9d41ffda82b3715b90e01d71b7a4681921" + ], + "version": "==1.0.0" + }, + "more-itertools": { + "hashes": [ + "sha256:11a625025954c20145b37ff6309cd54e39ca94f72f6bb9576d1195db6fa2442e", + "sha256:0dd8f72eeab0d2c3bd489025bb2f6a1b8342f9b198f6fc37b52d15cfa4531fea", + "sha256:c9ce7eccdcb901a2c75d326ea134e0886abfbea5f93e91cc95de9507c0816c44" + ], + "version": "==4.1.0" + }, + "pluggy": { + "hashes": [ + "sha256:d345c8fe681115900d6da8d048ba67c25df42973bda370783cd58826442dcd7c", + "sha256:e160a7fcf25762bb60efc7e171d4497ff1d8d2d75a3d0df7a21b76821ecbf5c5", + "sha256:7f8ae7f5bdf75671a718d2daf0a64b7885f74510bcd98b1a0bb420eb9a9d0cff" + ], + "version": "==0.6.0" + }, + "py": { + "hashes": [ + "sha256:983f77f3331356039fdd792e9220b7b8ee1aa6bd2b25f567a963ff1de5a64f6a", + "sha256:29c9fab495d7528e80ba1e343b958684f4ace687327e6f789a94bf3d1915f881" + ], + "version": "==1.5.3" + }, + "pyaml": { + "hashes": [ + "sha256:f83fc302c52c6b83a15345792693ae0b5bc07ad19f59e318b7617d7123d62990", + "sha256:66623c52f34d83a2c0fc963e08e8b9d0c13d88404e3b43b1852ef71eda19afa3" + ], + "version": "==17.12.1" + }, + "pytest": { + "hashes": [ + "sha256:829230122facf05a5f81a6d4dfe6454a04978ea3746853b2b84567ecf8e5c526", + "sha256:54713b26c97538db6ff0703a12b19aeaeb60b5e599de542e7fca0ec83b9038e8" + ], + "version": "==3.5.1" + }, + "pyyaml": { + "hashes": [ + "sha256:3262c96a1ca437e7e4763e2843746588a965426550f3797a79fca9c6199c431f", + "sha256:16b20e970597e051997d90dc2cddc713a2876c47e3d92d59ee198700c5427736", + "sha256:e863072cdf4c72eebf179342c94e6989c67185842d9997960b3e69290b2fa269", + "sha256:bc6bced57f826ca7cb5125a10b23fd0f2fff3b7c4701d64c439a300ce665fff8", + "sha256:c01b880ec30b5a6e6aa67b09a2fe3fb30473008c85cd6a67359a1b15ed6d83a4", + "sha256:827dc04b8fa7d07c44de11fabbc888e627fa8293b695e0f99cb544fdfa1bf0d1", + "sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab", + "sha256:5f84523c076ad14ff5e6c037fe1c89a7f73a3e04cf0377cb4d017014976433f3", + "sha256:0c507b7f74b3d2dd4d1322ec8a94794927305ab4cebbe89cc47fe5e81541e6e8", + "sha256:b4c423ab23291d3945ac61346feeb9a0dc4184999ede5e7c43e1ffb975130ae6", + "sha256:ca233c64c6e40eaa6c66ef97058cdc80e8d0157a443655baa1b2966e812807ca", + "sha256:4474f8ea030b5127225b8894d626bb66c01cda098d47a2b0d3429b6700af9fd8", + "sha256:326420cbb492172dec84b0f65c80942de6cedb5233c413dd824483989c000608", + "sha256:5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7" + ], + "version": "==3.12" + }, + "requests": { + "hashes": [ + "sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b", + "sha256:9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e" + ], + "version": "==2.18.4" + }, + "six": { + "hashes": [ + "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb", + "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9" + ], + "version": "==1.11.0" + }, + "unidecode": { + "hashes": [ + "sha256:72f49d3729f3d8f5799f710b97c1451c5163102e76d64d20e170aedbbd923582", + "sha256:8c33dd588e0c9bc22a76eaa0c715a5434851f726131bd44a6c26471746efabf5" + ], + "version": "==1.0.22" + }, + "urllib3": { + "hashes": [ + "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b", + "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f" + ], + "version": "==1.22" + } + }, + "develop": { + "backcall": { + "hashes": [ + "sha256:38ecd85be2c1e78f77fd91700c76e14667dc21e2713b63876c0eb901196e01e4", + "sha256:bbbf4b1e5cd2bdb08f915895b51081c041bac22394fdfcfdfbe9f14b77c08bf2" + ], + "version": "==0.1.0" + }, + "decorator": { + "hashes": [ + "sha256:2c51dff8ef3c447388fe5e4453d24a2bf128d3a4c32af3fabef1f01c6851ab82", + "sha256:c39efa13fbdeb4506c476c9b3babf6a718da943dab7811c206005a4a956c080c" + ], + "version": "==4.3.0" + }, + "ipython": { + "hashes": [ + "sha256:a0c96853549b246991046f32d19db7140f5b1a644cc31f0dc1edc86713b7676f", + "sha256:eca537aa61592aca2fef4adea12af8e42f5c335004dfa80c78caf80e8b525e5c" + ], + "version": "==6.4.0" + }, + "ipython-genutils": { + "hashes": [ + "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8", + "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8" + ], + "version": "==0.2.0" + }, + "jedi": { + "hashes": [ + "sha256:5861f6dc0c16e024cbb0044999f9cf8013b292c05f287df06d3d991a87a4eb89", + "sha256:1972f694c6bc66a2fac8718299e2ab73011d653a6d8059790c3476d2353b99ad" + ], + "version": "==0.12.0" + }, + "parso": { + "hashes": [ + "sha256:cdef26e8adc10d589f3ec4eb444bd0a29f3f1eb6d72a4292ab8afcb9d68976a6", + "sha256:f0604a40b96e062b0fd99cf134cc2d5cdf66939d0902f8267d938b0d5b26707f" + ], + "version": "==0.2.1" + }, + "pexpect": { + "hashes": [ + "sha256:9783f4644a3ef8528a6f20374eeb434431a650c797ca6d8df0d81e30fffdfa24", + "sha256:9f8eb3277716a01faafaba553d629d3d60a1a624c7cf45daa600d2148c30020c" + ], + "markers": "sys_platform != 'win32'", + "version": "==4.5.0" + }, + "pickleshare": { + "hashes": [ + "sha256:c9a2541f25aeabc070f12f452e1f2a8eae2abd51e1cd19e8430402bdf4c1d8b5", + "sha256:84a9257227dfdd6fe1b4be1319096c20eb85ff1e82c7932f36efccfe1b09737b" + ], + "version": "==0.7.4" + }, + "prompt-toolkit": { + "hashes": [ + "sha256:3f473ae040ddaa52b52f97f6b4a493cfa9f5920c255a12dc56a7d34397a398a4", + "sha256:1df952620eccb399c53ebb359cc7d9a8d3a9538cb34c5a1344bdbeb29fbcc381", + "sha256:858588f1983ca497f1cf4ffde01d978a3ea02b01c8a26a8bbc5cd2e66d816917" + ], + "version": "==1.0.15" + }, + "ptyprocess": { + "hashes": [ + "sha256:e8c43b5eee76b2083a9badde89fd1bbce6c8942d1045146e100b7b5e014f4f1a", + "sha256:e64193f0047ad603b71f202332ab5527c5e52aa7c8b609704fc28c0dc20c4365" + ], + "version": "==0.5.2" + }, + "pygments": { + "hashes": [ + "sha256:78f3f434bcc5d6ee09020f92ba487f95ba50f1e3ef83ae96b9d5ffa1bab25c5d", + "sha256:dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc" + ], + "version": "==2.2.0" + }, + "simplegeneric": { + "hashes": [ + "sha256:dc972e06094b9af5b855b3df4a646395e43d1c9d0d39ed345b7393560d0b9173" + ], + "version": "==0.8.1" + }, + "six": { + "hashes": [ + "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb", + "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9" + ], + "version": "==1.11.0" + }, + "traitlets": { + "hashes": [ + "sha256:c6cb5e6f57c5a9bdaa40fa71ce7b4af30298fbab9ece9815b5d995ab6217c7d9", + "sha256:9c4bd2d267b7153df9152698efb1050a5d84982d3384a37b2c1f7723ba3e7835" + ], + "version": "==4.3.2" + }, + "wcwidth": { + "hashes": [ + "sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c", + "sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e" + ], + "version": "==0.1.7" + } + } +} diff --git a/README.md b/README.md index c234fcf..eef46c2 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/allure/allure-report/.keep b/allure/allure-report/.keep new file mode 100644 index 0000000..e69de29 diff --git a/allure/invoke.yaml b/allure/invoke.yaml new file mode 100644 index 0000000..9543724 --- /dev/null +++ b/allure/invoke.yaml @@ -0,0 +1,2 @@ +api_url: +tests_files: diff --git a/allure/tasks.py b/allure/tasks.py new file mode 100644 index 0000000..0295ba2 --- /dev/null +++ b/allure/tasks.py @@ -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)