diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1fde2f33..4ecdd0b6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,6 +13,7 @@ Please write new test cases for new code you create. * If you're unable to find an open issue, [open a new one](https://github.com/ExpDev07/coronavirus-tracker-api/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible * Open a new [GitHub Pull Request to coronavirus-tracker-api](https://github.com/ExpDev07/coronavirus-tracker-api/pulls) with a clear list of what you've done (read more about [pull requests](http://help.github.com/pull-requests/)). Include the relevant issue number if applicable. * We will love you forever if you include unit tests. We can always use more test coverage +* If you have updated [Pipefile](./Pipfile), you have to update `Pipfile.lock`, `requirements.txt` and `requirements-dev.txt`. See section [Update requirements files](./README.md#update-requirements-files). ## Your First Code Contribution diff --git a/README.md b/README.md index 8fb2e962..cf8be2c3 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Support multiple data-sources. Currently 2 different data-sources are available to retrieve the data: -* **jhu** - https://github.com/CSSEGISandData/COVID-19 - Worldwide Data repository operated by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE). +* **jhu** - https://github.com/CSSEGISandData/COVID-19 - Worldwide Data repository operated by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE). * **csbs** - https://www.csbs.org/information-covid-19-coronavirus - U.S. County data that comes from the Conference of State Bank Supervisors. @@ -40,7 +40,7 @@ __jhu__ data-source will be used as a default source if you don't specify a *sou ## API Reference -All endpoints are located at ``coronavirus-tracker-api.herokuapp.com/v2/`` and are accessible via https. For instance: you can get data per location by using this URL: +All endpoints are located at ``coronavirus-tracker-api.herokuapp.com/v2/`` and are accessible via https. For instance: you can get data per location by using this URL: *[https://coronavirus-tracker-api.herokuapp.com/v2/locations](https://coronavirus-tracker-api.herokuapp.com/v2/locations)* You can open the URL in your browser to further inspect the response. Or you can make this curl call in your terminal to see the prettified response: @@ -56,7 +56,7 @@ Consume our API through [our super awesome and interactive SwaggerUI](https://co The [OpenAPI](https://swagger.io/docs/specification/about/) json definition can be downloaded at https://coronavirus-tracker-api.herokuapp.com/openapi.json -## API Endpoints +## API Endpoints ### Sources Endpoint @@ -365,7 +365,7 @@ These are the available API wrappers created by the community. They are not nece ### C# -* [CovidSharp by @Abdirahiim](https://github.com/Abdirahiim/covidtrackerapiwrapper) +* [CovidSharp by @Abdirahiim](https://github.com/Abdirahiim/covidtrackerapiwrapper) * [Covid19Tracker.NET by @egbakou](https://github.com/egbakou/Covid19Tracker.NET) ### Python @@ -408,7 +408,7 @@ You will need the following things properly installed on your computer. 3. Create virtual environment and install all dependencies `$ pipenv sync --dev` 4. Activate/enter the virtual environment `$ pipenv shell` -And don't despair if don't get the python setup working on the first try. No one did. Guido got pretty close... once. But that's another story. Good luck. +And don't despair if don't get the python setup working on the first try. No one did. Guido got pretty close... once. But that's another story. Good luck. ## Running / Development @@ -437,6 +437,14 @@ pipenv run lint pipenv run fmt ``` +### Update requirements files + +```bash +invoke generate-reqs +``` + +[Pipfile.lock](./Pipfile.lock) will be automatically updated during `pipenv install`. + ### Building ### Deploying diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..e85f4e9c --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,48 @@ +-i https://pypi.org/simple +appdirs==1.4.3 +astroid==2.3.3 +async-asgi-testclient==1.4.4 +async-generator==1.10 +asyncmock==0.4.2 +attrs==19.3.0 +bandit==1.6.2 +black==19.10b0 +certifi==2019.11.28 +chardet==3.0.4 +click==7.1.1 +coverage==5.0.4 +coveralls==1.11.1 +docopt==0.6.2 +gitdb==4.0.2 +gitpython==3.1.0 +idna==2.9 +importlib-metadata==1.6.0 ; python_version < '3.8' +invoke==1.4.1 +isort==4.3.21 +lazy-object-proxy==1.4.3 +mccabe==0.6.1 +mock==4.0.2 +more-itertools==8.2.0 +multidict==4.7.5 +packaging==20.3 +pathspec==0.7.0 +pbr==5.4.4 +pluggy==0.13.1 +py==1.8.1 +pylint==2.4.4 +pyparsing==2.4.6 +pytest-asyncio==0.10.0 +pytest-cov==2.8.1 +pytest==5.4.1 +pyyaml==5.3.1 +regex==2020.2.20 +requests==2.23.0 +six==1.14.0 +smmap==3.0.1 +stevedore==1.32.0 +toml==0.10.0 +typed-ast==1.4.1 +urllib3==1.25.8 +wcwidth==0.1.9 +wrapt==1.11.2 +zipp==3.1.0 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..0d7a2c46 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,28 @@ +-i https://pypi.org/simple +aiohttp==3.6.2 +async-timeout==3.0.1 +asyncache==0.1.1 +attrs==19.3.0 +cachetools==4.0.0 +certifi==2019.11.28 +chardet==3.0.4 +click==7.1.1 +dataclasses==0.6 ; python_version < '3.7' +fastapi==0.53.2 +gunicorn==20.0.4 +h11==0.9.0 +httptools==0.1.1 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy' +idna-ssl==1.1.0 ; python_version < '3.7' +idna==2.9 +multidict==4.7.5 +pydantic==1.4 +python-dateutil==2.8.1 +python-dotenv==0.12.0 +requests==2.23.0 +six==1.14.0 +starlette==0.13.2 +urllib3==1.25.8 +uvicorn==0.11.3 +uvloop==0.14.0 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy' +websockets==8.1 +yarl==1.4.2 diff --git a/tasks.py b/tasks.py index 3ff5f24c..bf2a60df 100644 --- a/tasks.py +++ b/tasks.py @@ -64,3 +64,10 @@ def lint(ctx): def test(ctx): """Run pytest tests.""" ctx.run(" ".join(["pytest", "-v"])) + + +@invoke.task +def generate_reqs(ctx): + """Generate requirements.txt""" + reqs = ["pipenv lock -r > requirements.txt", "pipenv lock -r --dev > requirements-dev.txt"] + [ctx.run(req) for req in reqs] diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 00000000..ec92cd25 --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,51 @@ +import subprocess + + +def test_invoke_list(): + """Test invoke --list""" + return_code = subprocess.call("invoke --list", shell=True) + + assert return_code == 0 + + +def test_requirements_txt(): + """Validate that requirements.txt and requirements-dev.txt + are up2date with Pipefile""" + temp_output_dir = "tests/temp_output" + req_test_file_path = "{}/test-requirements.txt".format(temp_output_dir) + req_dev_test_file_path = "{}/test-requirements-dev.txt".format(temp_output_dir) + + return_code_0 = subprocess.call("mkdir -p {}".format(temp_output_dir), shell=True) + return_code_1 = subprocess.call( + "pipenv lock -r \ + > {}".format( + req_test_file_path + ), + shell=True, + ) + + return_code_2 = subprocess.call( + "pipenv lock -r --dev \ + > {}".format( + req_dev_test_file_path + ), + shell=True, + ) + + with open("requirements.txt") as file: + req_file = file.read() + + with open("requirements-dev.txt") as file: + req_dev_file = file.read() + + with open(req_test_file_path) as file: + req_test_file = file.read() + + with open(req_dev_test_file_path) as file: + req_dev_test_file = file.read() + + return_code_z = subprocess.call("rm -rf {}".format(temp_output_dir), shell=True) + + assert req_file == req_test_file + + assert req_dev_file == req_dev_test_file