This repository was archived by the owner on Jun 24, 2024. It is now read-only.
File tree 3 files changed +57
-0
lines changed
3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ # This workflow will install Python dependencies, run tests and lint with a single version of Python
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
+
4
+ name : Pytest
5
+
6
+ on : [push]
7
+
8
+ permissions :
9
+ contents : read
10
+
11
+ jobs :
12
+ build :
13
+
14
+ runs-on : ubuntu-latest
15
+
16
+ steps :
17
+ - uses : actions/checkout@v3
18
+ - name : Set up Python 3.10.13
19
+ uses : actions/setup-python@v3
20
+ with :
21
+ python-version : " 3.10.13"
22
+ - name : Install dependencies
23
+ run : |
24
+ python -m pip install --upgrade pip
25
+ pip install -r requirements/tests/requirements.txt
26
+ - name : Test with pytest
27
+ run : |
28
+ pytest tests/
Original file line number Diff line number Diff line change
1
+ pytest
2
+ requests
Original file line number Diff line number Diff line change
1
+ """
2
+ Tests for the API
3
+ """
4
+
5
+ import requests
6
+
7
+ URLS_API = ["http://hessian.be/api" , "http://hessian.be/api/billing" ]
8
+
9
+ def test_api_status ():
10
+ """
11
+ Test that the API is:
12
+ (1) reachable
13
+ (2) available (i.e. returns status code 200)
14
+ """
15
+
16
+ for url in URLS_API :
17
+
18
+ # (1) Check if the API is reachable
19
+ try :
20
+ response = requests .get (url , timeout = 5 )
21
+ except requests .exceptions .RequestException as e :
22
+ error = f"Error occured while trying to API `{ url } `: { e } "
23
+ raise requests .exceptions .RequestException (error )
24
+
25
+ # (2) Check if the API is available
26
+ assert response .status_code == 200 , \
27
+ f"API `{ url } ` is reachable but returned status code { response .status_code } "
You can’t perform that action at this time.
0 commit comments