Skip to content

Commit

Permalink
Setup offline testing in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Oct 27, 2024
1 parent ae98c20 commit 299b464
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ jobs:
pip3 install -r docs/requirements.txt
- name: run tests ⚙️
run: python3 -m pytest
- name: run tests in offline mode
if: matrix.python-version == '3.10'
run: |
python3 -m pytest \
-m "not online" \
--disable-socket \
--deselect="tests/doctests/wcs_thredds.txt::wcs_thredds.txt" \
--deselect="tests/doctests/wfs_MapServerWFSCapabilities.txt::wfs_MapServerWFSCapabilities.txt" \
--deselect="tests/doctests/wms_geoserver_mass_gis.txt::wms_geoserver_mass_gis.txt"
- name: run coveralls ⚙️
run: coveralls
- name: build docs 🏗️
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
flake8
pytest
pytest-cov
pytest-socket
Pillow
tox
twine
Expand Down
1 change: 1 addition & 0 deletions tests/test_csw_geonetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def test_csw_geonetwork():

SERVICE_URL3 = 'https://metawal.wallonie.be/geonetwork/srv/eng/csw'

@pytest.mark.online
@pytest.mark.skipif(not service_ok(SERVICE_URL3),
reason='service is unreachable')
@pytest.mark.parametrize("esn_in", ['full', 'summary'])
Expand Down
5 changes: 5 additions & 0 deletions tests/test_ogcapi_connectedsystems_osh.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def update_dsid(self, ds_id):
class TestSystems:
fixtures = OSHFixtures()

@pytest.mark.online
def test_system_readonly(self):
# get all systems
res = self.fixtures.systems_api.systems()
Expand Down Expand Up @@ -250,6 +251,7 @@ def test_deployment_delete(self):
class TestSamplingFeatures:
fixtures = OSHFixtures()

@pytest.mark.online
def test_sampling_features_readonly(self):
all_features = self.fixtures.sampling_feature_api.sampling_features(use_fois=True)
assert len(all_features['items']) == 51
Expand Down Expand Up @@ -296,6 +298,7 @@ def test_sampling_features_all(self):
class TestDatastreams:
fixtures = OSHFixtures()

@pytest.mark.online
def test_datastreams_readonly(self):
ds_id = 'kjg2qrcm40rfk'
datastreams = self.fixtures.datastream_api.datastreams()
Expand Down Expand Up @@ -342,6 +345,7 @@ def test_all_ds_functions(self):
class TestObservations:
fixtures = OSHFixtures()

@pytest.mark.online
def test_observations_readonly(self):
ds_id = 'kjg2qrcm40rfk'
observations = self.fixtures.observations_api.observations_of_datastream(ds_id)
Expand Down Expand Up @@ -383,6 +387,7 @@ def test_observations(self):
class TestSystemHistory:
fixtures = OSHFixtures()

@pytest.mark.online
def test_system_history(self):
sys_id = '0s2lbn2n1bnc8'
res = self.fixtures.system_history_api.system_history(sys_id)
Expand Down
14 changes: 13 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
[pytest]
addopts = -v -rxs -s --color=yes --tb=native --ignore=setup.py --doctest-modules --doctest-glob 'tests/**/*.txt' --cov-report term-missing --cov owslib
addopts =
-v
-rxs
-s
--color=yes
--tb=native
--ignore=setup.py
--doctest-modules
--doctest-glob='tests/**/*.txt'
--cov-report=term-missing
--cov=owslib
--allow-hosts=127.0.0.1,127.0.1.1

norecursedirs = .git docs examples etc cov* *.egg* pytest* .tox _broken
markers =
online: test requires online resources.
Expand Down

0 comments on commit 299b464

Please sign in to comment.