Skip to content

Commit c9eb974

Browse files
committed
Make tests pytest compatible
1 parent 707135a commit c9eb974

27 files changed

+96
-9
lines changed

docs/epidata_development.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ The final line of output should be similar to the following:
143143
All 48 tests passed! 68% (490/711) coverage.
144144
```
145145

146+
You can also run tests using pytest like this:
147+
```
148+
docker run --rm delphi_python pytest repos/delphi/delphi-epidata/tests/
149+
```
150+
and with pdb enabled like this:
151+
```
152+
docker run -it --rm delphi_python pytest repos/delphi/delphi-epidata/tests/ --pdb
153+
```
154+
146155
## manual tests
147156

148157
You can test your changes manually by:

docs/new_endpoint_tutorial.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ If all succeeds, output should look like this:
267267
✔ All 48 tests passed! 69% (486/704) coverage.
268268
```
269269

270+
You can also run tests using pytest like this:
271+
```
272+
docker run --rm delphi_python pytest repos/delphi/delphi-epidata/tests/
273+
```
274+
and with pdb enabled like this:
275+
```
276+
docker run -it --rm delphi_python pytest repos/delphi/delphi-epidata/tests/ --pdb
277+
```
278+
270279
## integration
271280

272281
Integration tests require more effort and take longer to set up and run.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import sys
2+
import os
3+
4+
sys.path.append(os.getcwd())

tests/acquisition/covid_hosp/common/test_database.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
# third party
1010
import pandas as pd
1111

12+
from delphi.epidata.acquisition.covid_hosp.common.database import Database
13+
1214
# py3tester coverage target
1315
__test_target__ = 'delphi.epidata.acquisition.covid_hosp.common.database'
1416

tests/acquisition/covid_hosp/common/test_network.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
from unittest.mock import MagicMock
66
from unittest.mock import sentinel
77

8+
from delphi.epidata.acquisition.covid_hosp.common.network import Network
9+
810
# py3tester coverage target
911
__test_target__ = 'delphi.epidata.acquisition.covid_hosp.common.network'
1012

1113

14+
1215
class NetworkTests(unittest.TestCase):
1316

1417
def test_fetch_metadata_for_dataset(self):

tests/acquisition/covid_hosp/common/test_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# first party
99
from delphi.epidata.acquisition.covid_hosp.common.test_utils import TestUtils
10+
from delphi.epidata.acquisition.covid_hosp.common.utils import Utils, CovidHospException
1011

1112
# py3tester coverage target
1213
__test_target__ = 'delphi.epidata.acquisition.covid_hosp.common.utils'
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import sys
2+
import os
3+
4+
sys.path.append(os.getcwd())

tests/acquisition/covid_hosp/facility/test_database.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# first party
99
from delphi.epidata.acquisition.covid_hosp.common.test_utils import TestUtils
10+
from delphi.epidata.acquisition.covid_hosp.facility.database import Database
1011

1112
# py3tester coverage target
1213
__test_target__ = 'delphi.epidata.acquisition.covid_hosp.facility.database'

tests/acquisition/covid_hosp/facility/test_network.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from unittest.mock import patch
66
from unittest.mock import sentinel
77

8+
from delphi.epidata.acquisition.covid_hosp.facility.network import Network
9+
810
# py3tester coverage target
911
__test_target__ = 'delphi.epidata.acquisition.covid_hosp.facility.network'
1012

tests/acquisition/covid_hosp/facility/test_update.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# first party
99
from delphi.epidata.acquisition.covid_hosp.common.utils import Utils
10+
from delphi.epidata.acquisition.covid_hosp.facility.update import Update
1011

1112
# py3tester coverage target
1213
__test_target__ = 'delphi.epidata.acquisition.covid_hosp.facility.update'

0 commit comments

Comments
 (0)