Skip to content

Commit

Permalink
Add requirements.txt files (#245)
Browse files Browse the repository at this point in the history
* Add requirements.txt files #244

* Add testcases to validate requirements.txt

* update reqs and contrib guide

* fix formatting for edit files
  • Loading branch information
gribok committed Apr 3, 2020
1 parent 2b2fc19 commit 1f205f4
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 5 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ 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.

__jhu__ data-source will be used as a default source if you don't specify a *source parameter* in your request.

## 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:
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
51 changes: 51 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1f205f4

Please sign in to comment.