Skip to content

Commit dc26c95

Browse files
authored
Add GitHub actions (#2) (#41)
1 parent eb75cc8 commit dc26c95

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: GitHub Actions Tests
2+
on: [push, pull_request]
3+
jobs:
4+
Execute-Tests:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
8+
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
9+
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
10+
- name: Check out repository code
11+
uses: actions/checkout@v2
12+
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
13+
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
14+
- name: List files in the repository
15+
run: |
16+
ls ${{ github.workspace }}
17+
- run: pip install -r requirements.txt
18+
- run: python -m unittest
19+
- run: echo "🍏 This job's status is ${{ job.status }}."

code/__init__.py

Whitespace-only changes.

main.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import uvicorn
22
from fastapi import FastAPI
3-
import sys
4-
sys.path.insert(0, './code')
5-
import data
3+
4+
from code import data
65

76
app = FastAPI()
87
# Load the data in dataframe format
98
df = data.getDataframe()
109

10+
1111
@app.get('/')
1212
def root():
13-
print(list(df.keys()))
1413
return {'message': 'Hello world!'}
1514

15+
1616
@app.get('/tests')
1717
def list_tests():
18-
print("Number of test unique: ", len(list(df['manufacturer'].unique())))
18+
print("Number of manufacturers of covid tests unique: ", len(list(df['manufacturer'].unique())))
1919
return list(df['manufacturer'].unique())
2020

21+
2122
if __name__ == '__main__':
22-
uvicorn.run('main:app', host='0.0.0.0', reload=True)
23+
uvicorn.run('main:app', host='0.0.0.0', reload=True)

test.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import unittest
12
from unittest import TestCase
23

34
from fastapi.testclient import TestClient
@@ -7,6 +8,13 @@
78

89
class TestCovidEndpoints(TestCase):
910

11+
def test_root_endpoint_works(self):
12+
client = TestClient(app)
13+
14+
response = client.get('/')
15+
16+
self.assertEqual(response.status_code, 200)
17+
1018
def test_list_endpoint_works(self):
1119
client = TestClient(app)
1220

@@ -22,3 +30,7 @@ def test_not_exists_endpoint_is_404(self):
2230
self.assertEqual(response.status_code, 404)
2331

2432

33+
if __name__ == '__main__':
34+
unittest.main()
35+
36+

0 commit comments

Comments
 (0)