Skip to content

Commit 1f205f4

Browse files
authored
Add requirements.txt files (#245)
* Add requirements.txt files #244 * Add testcases to validate requirements.txt * update reqs and contrib guide * fix formatting for edit files
1 parent 2b2fc19 commit 1f205f4

File tree

6 files changed

+148
-5
lines changed

6 files changed

+148
-5
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Please write new test cases for new code you create.
1313
* 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
1414
* 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.
1515
* We will love you forever if you include unit tests. We can always use more test coverage
16+
* 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).
1617

1718
## Your First Code Contribution
1819

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ Support multiple data-sources.
3232

3333
Currently 2 different data-sources are available to retrieve the data:
3434

35-
* **jhu** - https://github.com/CSSEGISandData/COVID-19 - Worldwide Data repository operated by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE).
35+
* **jhu** - https://github.com/CSSEGISandData/COVID-19 - Worldwide Data repository operated by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE).
3636

3737
* **csbs** - https://www.csbs.org/information-covid-19-coronavirus - U.S. County data that comes from the Conference of State Bank Supervisors.
3838

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

4141
## API Reference
4242

43-
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:
43+
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:
4444
*[https://coronavirus-tracker-api.herokuapp.com/v2/locations](https://coronavirus-tracker-api.herokuapp.com/v2/locations)*
4545

4646
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
5656

5757
The [OpenAPI](https://swagger.io/docs/specification/about/) json definition can be downloaded at https://coronavirus-tracker-api.herokuapp.com/openapi.json
5858

59-
## API Endpoints
59+
## API Endpoints
6060

6161
### Sources Endpoint
6262

@@ -365,7 +365,7 @@ These are the available API wrappers created by the community. They are not nece
365365

366366
### C#
367367

368-
* [CovidSharp by @Abdirahiim](https://github.com/Abdirahiim/covidtrackerapiwrapper)
368+
* [CovidSharp by @Abdirahiim](https://github.com/Abdirahiim/covidtrackerapiwrapper)
369369
* [Covid19Tracker.NET by @egbakou](https://github.com/egbakou/Covid19Tracker.NET)
370370

371371
### Python
@@ -408,7 +408,7 @@ You will need the following things properly installed on your computer.
408408
3. Create virtual environment and install all dependencies `$ pipenv sync --dev`
409409
4. Activate/enter the virtual environment `$ pipenv shell`
410410

411-
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.
411+
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.
412412

413413
## Running / Development
414414

@@ -437,6 +437,14 @@ pipenv run lint
437437
pipenv run fmt
438438
```
439439

440+
### Update requirements files
441+
442+
```bash
443+
invoke generate-reqs
444+
```
445+
446+
[Pipfile.lock](./Pipfile.lock) will be automatically updated during `pipenv install`.
447+
440448
### Building
441449

442450
### Deploying

requirements-dev.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
-i https://pypi.org/simple
2+
appdirs==1.4.3
3+
astroid==2.3.3
4+
async-asgi-testclient==1.4.4
5+
async-generator==1.10
6+
asyncmock==0.4.2
7+
attrs==19.3.0
8+
bandit==1.6.2
9+
black==19.10b0
10+
certifi==2019.11.28
11+
chardet==3.0.4
12+
click==7.1.1
13+
coverage==5.0.4
14+
coveralls==1.11.1
15+
docopt==0.6.2
16+
gitdb==4.0.2
17+
gitpython==3.1.0
18+
idna==2.9
19+
importlib-metadata==1.6.0 ; python_version < '3.8'
20+
invoke==1.4.1
21+
isort==4.3.21
22+
lazy-object-proxy==1.4.3
23+
mccabe==0.6.1
24+
mock==4.0.2
25+
more-itertools==8.2.0
26+
multidict==4.7.5
27+
packaging==20.3
28+
pathspec==0.7.0
29+
pbr==5.4.4
30+
pluggy==0.13.1
31+
py==1.8.1
32+
pylint==2.4.4
33+
pyparsing==2.4.6
34+
pytest-asyncio==0.10.0
35+
pytest-cov==2.8.1
36+
pytest==5.4.1
37+
pyyaml==5.3.1
38+
regex==2020.2.20
39+
requests==2.23.0
40+
six==1.14.0
41+
smmap==3.0.1
42+
stevedore==1.32.0
43+
toml==0.10.0
44+
typed-ast==1.4.1
45+
urllib3==1.25.8
46+
wcwidth==0.1.9
47+
wrapt==1.11.2
48+
zipp==3.1.0

requirements.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-i https://pypi.org/simple
2+
aiohttp==3.6.2
3+
async-timeout==3.0.1
4+
asyncache==0.1.1
5+
attrs==19.3.0
6+
cachetools==4.0.0
7+
certifi==2019.11.28
8+
chardet==3.0.4
9+
click==7.1.1
10+
dataclasses==0.6 ; python_version < '3.7'
11+
fastapi==0.53.2
12+
gunicorn==20.0.4
13+
h11==0.9.0
14+
httptools==0.1.1 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
15+
idna-ssl==1.1.0 ; python_version < '3.7'
16+
idna==2.9
17+
multidict==4.7.5
18+
pydantic==1.4
19+
python-dateutil==2.8.1
20+
python-dotenv==0.12.0
21+
requests==2.23.0
22+
six==1.14.0
23+
starlette==0.13.2
24+
urllib3==1.25.8
25+
uvicorn==0.11.3
26+
uvloop==0.14.0 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
27+
websockets==8.1
28+
yarl==1.4.2

tasks.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,10 @@ def lint(ctx):
6464
def test(ctx):
6565
"""Run pytest tests."""
6666
ctx.run(" ".join(["pytest", "-v"]))
67+
68+
69+
@invoke.task
70+
def generate_reqs(ctx):
71+
"""Generate requirements.txt"""
72+
reqs = ["pipenv lock -r > requirements.txt", "pipenv lock -r --dev > requirements-dev.txt"]
73+
[ctx.run(req) for req in reqs]

tests/test_cli.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import subprocess
2+
3+
4+
def test_invoke_list():
5+
"""Test invoke --list"""
6+
return_code = subprocess.call("invoke --list", shell=True)
7+
8+
assert return_code == 0
9+
10+
11+
def test_requirements_txt():
12+
"""Validate that requirements.txt and requirements-dev.txt
13+
are up2date with Pipefile"""
14+
temp_output_dir = "tests/temp_output"
15+
req_test_file_path = "{}/test-requirements.txt".format(temp_output_dir)
16+
req_dev_test_file_path = "{}/test-requirements-dev.txt".format(temp_output_dir)
17+
18+
return_code_0 = subprocess.call("mkdir -p {}".format(temp_output_dir), shell=True)
19+
return_code_1 = subprocess.call(
20+
"pipenv lock -r \
21+
> {}".format(
22+
req_test_file_path
23+
),
24+
shell=True,
25+
)
26+
27+
return_code_2 = subprocess.call(
28+
"pipenv lock -r --dev \
29+
> {}".format(
30+
req_dev_test_file_path
31+
),
32+
shell=True,
33+
)
34+
35+
with open("requirements.txt") as file:
36+
req_file = file.read()
37+
38+
with open("requirements-dev.txt") as file:
39+
req_dev_file = file.read()
40+
41+
with open(req_test_file_path) as file:
42+
req_test_file = file.read()
43+
44+
with open(req_dev_test_file_path) as file:
45+
req_dev_test_file = file.read()
46+
47+
return_code_z = subprocess.call("rm -rf {}".format(temp_output_dir), shell=True)
48+
49+
assert req_file == req_test_file
50+
51+
assert req_dev_file == req_dev_test_file

0 commit comments

Comments
 (0)