File tree 4 files changed +38
-6
lines changed
4 files changed +38
-6
lines changed Original file line number Diff line number Diff line change
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 }}."
Original file line number Diff line number Diff line change 1
1
import uvicorn
2
2
from fastapi import FastAPI
3
- import sys
4
- sys .path .insert (0 , './code' )
5
- import data
3
+
4
+ from code import data
6
5
7
6
app = FastAPI ()
8
7
# Load the data in dataframe format
9
8
df = data .getDataframe ()
10
9
10
+
11
11
@app .get ('/' )
12
12
def root ():
13
- print (list (df .keys ()))
14
13
return {'message' : 'Hello world!' }
15
14
15
+
16
16
@app .get ('/tests' )
17
17
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 ())))
19
19
return list (df ['manufacturer' ].unique ())
20
20
21
+
21
22
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 )
Original file line number Diff line number Diff line change
1
+ import unittest
1
2
from unittest import TestCase
2
3
3
4
from fastapi .testclient import TestClient
7
8
8
9
class TestCovidEndpoints (TestCase ):
9
10
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
+
10
18
def test_list_endpoint_works (self ):
11
19
client = TestClient (app )
12
20
@@ -22,3 +30,7 @@ def test_not_exists_endpoint_is_404(self):
22
30
self .assertEqual (response .status_code , 404 )
23
31
24
32
33
+ if __name__ == '__main__' :
34
+ unittest .main ()
35
+
36
+
You can’t perform that action at this time.
0 commit comments