geopython / OWSLib

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.
https://owslib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
393 stars 278 forks source link

`tests/test_ogcapi_connectedsystems_osh.py` requires Internet but not marked as `online` #951

Closed mgorny closed 2 weeks ago

mgorny commented 1 month ago

When running the test suite in a container isolated from the Internet, with -m "not online" option, it started failing in 0.32.0 release:

========================================================= test session starts =========================================================
platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0 -- /tmp/portage/dev-python/owslib-0.32.0/work/OWSLib-0.32.0-python3_12/install/usr/bin/python3.12
cachedir: .pytest_cache
rootdir: /tmp/portage/dev-python/owslib-0.32.0/work/OWSLib-0.32.0
configfile: tox.ini
collecting ... collected 239 items / 1 error / 71 deselected / 168 selected

=============================================================== ERRORS ================================================================
_____________________________________ ERROR collecting tests/test_ogcapi_connectedsystems_osh.py ______________________________________
/usr/lib/python3.12/site-packages/urllib3/connection.py:199: in _new_conn
    sock = connection.create_connection(
        self       = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>
/usr/lib/python3.12/site-packages/urllib3/util/connection.py:85: in create_connection
    raise err
        address    = ('34.67.197.57', 8585)
        af         = <AddressFamily.AF_INET: 2>
        canonname  = ''
        err        = None
        family     = <AddressFamily.AF_UNSPEC: 0>
        host       = '34.67.197.57'
        port       = 8585
        proto      = 6
        res        = (<AddressFamily.AF_INET: 2>,
 <SocketKind.SOCK_STREAM: 1>,
 6,
 '',
 ('34.67.197.57', 8585))
        sa         = ('34.67.197.57', 8585)
        sock       = <socket.socket [closed] fd=-1, family=2, type=1, proto=6>
        socket_options = [(6, 1, 1)]
        socktype   = <SocketKind.SOCK_STREAM: 1>
        source_address = None
        timeout    = None
/usr/lib/python3.12/site-packages/urllib3/util/connection.py:73: in create_connection
    sock.connect(sa)
E   OSError: [Errno 101] Network is unreachable
        address    = ('34.67.197.57', 8585)
        af         = <AddressFamily.AF_INET: 2>
        canonname  = ''
        err        = None
        family     = <AddressFamily.AF_UNSPEC: 0>
        host       = '34.67.197.57'
        port       = 8585
        proto      = 6
        res        = (<AddressFamily.AF_INET: 2>,
 <SocketKind.SOCK_STREAM: 1>,
 6,
 '',
 ('34.67.197.57', 8585))
        sa         = ('34.67.197.57', 8585)
        sock       = <socket.socket [closed] fd=-1, family=2, type=1, proto=6>
        socket_options = [(6, 1, 1)]
        socktype   = <SocketKind.SOCK_STREAM: 1>
        source_address = None
        timeout    = None

The above exception was the direct cause of the following exception:
/usr/lib/python3.12/site-packages/urllib3/connectionpool.py:789: in urlopen
    response = self._make_request(
        assert_same_host = False
        body       = None
        body_pos   = None
        chunked    = False
        clean_exit = False
        conn       = None
        decode_content = False
        destination_scheme = None
        err        = None
        headers    = {'User-Agent': 'OWSLib 0.32.0 (https://owslib.readthedocs.io)', 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Authorization': 'Basic YXV0b190ZXN0OmF1dG9tYXRlZF90ZXN0ZXIyNA=='}
        http_tunnel_required = False
        method     = 'GET'
        new_e      = NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>: Failed to establish a new connection: [Errno 101] Network is unreachable')
        parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/sensorhub/api/', query=None, fragment=None)
        pool_timeout = None
        preload_content = False
        redirect   = False
        release_conn = False
        release_this_conn = True
        response_conn = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>
        response_kw = {}
        retries    = Retry(total=0, connect=None, read=False, redirect=None, status=None)
        self       = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f0d8dbed790>
        timeout    = Timeout(connect=None, read=None, total=None)
        timeout_obj = Timeout(connect=None, read=None, total=None)
        url        = '/sensorhub/api/'
/usr/lib/python3.12/site-packages/urllib3/connectionpool.py:495: in _make_request
    conn.request(
        body       = None
        chunked    = False
        conn       = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>
        decode_content = False
        enforce_content_length = True
        headers    = {'User-Agent': 'OWSLib 0.32.0 (https://owslib.readthedocs.io)', 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Authorization': 'Basic YXV0b190ZXN0OmF1dG9tYXRlZF90ZXN0ZXIyNA=='}
        method     = 'GET'
        preload_content = False
        response_conn = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>
        retries    = Retry(total=0, connect=None, read=False, redirect=None, status=None)
        self       = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f0d8dbed790>
        timeout    = Timeout(connect=None, read=None, total=None)
        timeout_obj = Timeout(connect=None, read=None, total=None)
        url        = '/sensorhub/api/'
/usr/lib/python3.12/site-packages/urllib3/connection.py:441: in request
    self.endheaders()
        body       = None
        chunked    = False
        chunks     = None
        chunks_and_cl = ChunksAndContentLength(chunks=None, content_length=None)
        content_length = None
        decode_content = False
        enforce_content_length = True
        header     = 'Authorization'
        header_keys = frozenset({'accept',
           'accept-encoding',
           'authorization',
           'connection',
           'content-type',
           'user-agent'})
        headers    = {'User-Agent': 'OWSLib 0.32.0 (https://owslib.readthedocs.io)', 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Authorization': 'Basic YXV0b190ZXN0OmF1dG9tYXRlZF90ZXN0ZXIyNA=='}
        method     = 'GET'
        preload_content = False
        self       = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>
        skip_accept_encoding = True
        skip_host  = False
        url        = '/sensorhub/api/'
        value      = 'Basic YXV0b190ZXN0OmF1dG9tYXRlZF90ZXN0ZXIyNA=='
/usr/lib/python3.12/http/client.py:1331: in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
        encode_chunked = False
        message_body = None
        self       = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>
/usr/lib/python3.12/http/client.py:1091: in _send_output
    self.send(msg)
        encode_chunked = False
        message_body = None
        msg        = (b'GET /sensorhub/api/ HTTP/1.1\r\nHost: 34.67.197.57:8585\r\nUser-Agent: OWSLi'
 b'b 0.32.0 (https://owslib.readthedocs.io)\r\nAccept-Encoding: gzip, deflate'
 b', br, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Type: appli'
 b'cation/json\r\nAuthorization: Basic YXV0b190ZXN0OmF1dG9tYXRlZF90ZXN0ZXIyNA'
 b'==\r\n\r\n')
        self       = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>
/usr/lib/python3.12/http/client.py:1035: in send
    self.connect()
        data       = (b'GET /sensorhub/api/ HTTP/1.1\r\nHost: 34.67.197.57:8585\r\nUser-Agent: OWSLi'
 b'b 0.32.0 (https://owslib.readthedocs.io)\r\nAccept-Encoding: gzip, deflate'
 b', br, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Type: appli'
 b'cation/json\r\nAuthorization: Basic YXV0b190ZXN0OmF1dG9tYXRlZF90ZXN0ZXIyNA'
 b'==\r\n\r\n')
        self       = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>
/usr/lib/python3.12/site-packages/urllib3/connection.py:279: in connect
    self.sock = self._new_conn()
        self       = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>
/usr/lib/python3.12/site-packages/urllib3/connection.py:214: in _new_conn
    raise NewConnectionError(
E   urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>: Failed to establish a new connection: [Errno 101] Network is unreachable
        self       = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>

The above exception was the direct cause of the following exception:
/usr/lib/python3.12/site-packages/requests/adapters.py:667: in send
    resp = conn.urlopen(
        cert       = None
        chunked    = False
        conn       = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f0d8dbed790>
        proxies    = OrderedDict()
        request    = <PreparedRequest [GET]>
        self       = <requests.adapters.HTTPAdapter object at 0x7f0d8dbed5b0>
        stream     = False
        timeout    = Timeout(connect=None, read=None, total=None)
        url        = '/sensorhub/api/'
        verify     = True
/usr/lib/python3.12/site-packages/urllib3/connectionpool.py:843: in urlopen
    retries = retries.increment(
        assert_same_host = False
        body       = None
        body_pos   = None
        chunked    = False
        clean_exit = False
        conn       = None
        decode_content = False
        destination_scheme = None
        err        = None
        headers    = {'User-Agent': 'OWSLib 0.32.0 (https://owslib.readthedocs.io)', 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Authorization': 'Basic YXV0b190ZXN0OmF1dG9tYXRlZF90ZXN0ZXIyNA=='}
        http_tunnel_required = False
        method     = 'GET'
        new_e      = NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>: Failed to establish a new connection: [Errno 101] Network is unreachable')
        parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/sensorhub/api/', query=None, fragment=None)
        pool_timeout = None
        preload_content = False
        redirect   = False
        release_conn = False
        release_this_conn = True
        response_conn = <urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>
        response_kw = {}
        retries    = Retry(total=0, connect=None, read=False, redirect=None, status=None)
        self       = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f0d8dbed790>
        timeout    = Timeout(connect=None, read=None, total=None)
        timeout_obj = Timeout(connect=None, read=None, total=None)
        url        = '/sensorhub/api/'
/usr/lib/python3.12/site-packages/urllib3/util/retry.py:519: in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
E   urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='34.67.197.57', port=8585): Max retries exceeded with url: /sensorhub/api/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))
        _pool      = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f0d8dbed790>
        _stacktrace = <traceback object at 0x7f0d8d677200>
        cause      = 'unknown'
        connect    = None
        error      = NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>: Failed to establish a new connection: [Errno 101] Network is unreachable')
        history    = (RequestHistory(method='GET', url='/sensorhub/api/', error=NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>: Failed to establish a new connection: [Errno 101] Network is unreachable'), status=None, redirect_location=None),)
        method     = 'GET'
        new_retry  = Retry(total=-1, connect=None, read=False, redirect=None, status=None)
        other      = None
        read       = False
        reason     = NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>: Failed to establish a new connection: [Errno 101] Network is unreachable')
        redirect   = None
        redirect_location = None
        response   = None
        self       = Retry(total=0, connect=None, read=False, redirect=None, status=None)
        status     = None
        status_count = None
        total      = -1
        url        = '/sensorhub/api/'

During handling of the above exception, another exception occurred:
tests/test_ogcapi_connectedsystems_osh.py:19: in <module>
    class OSHFixtures:
        Authentication = <class 'owslib.util.Authentication'>
        Commands   = <class 'owslib.ogcapi.connectedsystems.Commands'>
        ControlChannels = <class 'owslib.ogcapi.connectedsystems.ControlChannels'>
        Datastreams = <class 'owslib.ogcapi.connectedsystems.Datastreams'>
        Deployments = <class 'owslib.ogcapi.connectedsystems.Deployments'>
        Observations = <class 'owslib.ogcapi.connectedsystems.Observations'>
        Properties = <class 'owslib.ogcapi.connectedsystems.Properties'>
        SamplingFeatures = <class 'owslib.ogcapi.connectedsystems.SamplingFeatures'>
        SystemEvents = <class 'owslib.ogcapi.connectedsystems.SystemEvents'>
        SystemHistory = <class 'owslib.ogcapi.connectedsystems.SystemHistory'>
        Systems    = <class 'owslib.ogcapi.connectedsystems.Systems'>
        __builtins__ = <builtins>
        __cached__ = '/tmp/portage/dev-python/owslib-0.32.0/work/OWSLib-0.32.0/tests/__pycache__/test_ogcapi_connectedsystems_osh.cpython-312.pyc'
        __doc__    = None
        __file__   = '/tmp/portage/dev-python/owslib-0.32.0/work/OWSLib-0.32.0/tests/test_ogcapi_connectedsystems_osh.py'
        __loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7f0d92826cc0>
        __name__   = 'tests.test_ogcapi_connectedsystems_osh'
        __package__ = 'tests'
        __spec__   = ModuleSpec(name='tests.test_ogcapi_connectedsystems_osh', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7f0d92826cc0>, origin='/tmp/portage/dev-python/owslib-0.32.0/work/OWSLib-0.32.0/tests/test_ogcapi_connectedsystems_osh.py')
        datetime   = <class 'datetime.datetime'>
        json       = <module 'json' from '/usr/lib/python3.12/json/__init__.py'>
        pytest     = <module 'pytest' from '/usr/lib/python3.12/site-packages/pytest/__init__.py'>
tests/test_ogcapi_connectedsystems_osh.py:164: in OSHFixtures
    systems_api = Systems(TEST_URL, auth=auth, headers={'Content-Type': 'application/json'})
        NODE_TEST_OK_URL = 'http://34.67.197.57:8585/sensorhub/test'
        TEST_URL   = 'http://34.67.197.57:8585/sensorhub/api/'
        __module__ = 'tests.test_ogcapi_connectedsystems_osh'
        __qualname__ = 'OSHFixtures'
        auth       = <Authentication shared=False username=auto_test password=automated_tester24 cert=None verify=True auth_delegate=None>
        datastream_id = 'etbrve0msmrre'
        deployment_definition = {'properties': {'description': 'A test deployment',
                'featureType': 'http://www.w3.org/ns/sosa/Deployment',
                'name': 'Test Deployment 001',
                'uid': 'urn:osh:sensor:testdeployment:001',
                'validTime': ['2024-01-01T00:00:00Z', '2024-12-31T23:59:59Z']},
 'type': 'Feature'}
        deployment_expected_id = 'vssamsrio5eb2'
        ds_definition = {'name': 'Test Datastream',
 'outputName': 'Test Output #1',
 'schema': {'encoding': {'type': 'JSONEncoding', 'vectorAsArrays': False},
            'obsFormat': 'application/swe+json',
            'recordSchema': {'definition': 'http://test.com/Record',
                             'fields': [{'definition': 'http://test.com/Time',
                                         'label': 'Test Datastream Time',
                                         'name': 'timestamp',
                                         'optional': False,
                                         'type': 'Time',
                                         'uom': {'href': 'http://test.com/TimeUOM'},
                                         'updatable': False},
                                        {'definition': 'http://test.com/Boolean',
                                         'label': 'Test Datastream Boolean',
                                         'name': 'testboolean',
                                         'optional': False,
                                         'type': 'Boolean',
                                         'updatable': False}],
                             'label': 'Test Datastream Record',
                             'optional': False,
                             'type': 'DataRecord',
                             'updatable': False}}}
        feature_def = {'geometry': {'coordinates': [-80.0, 35.0], 'type': 'Point'},
 'properties': {'description': 'A test station',
                'featureType': 'http://www.w3.org/ns/sosa/Station',
                'name': 'Test Station 001',
                'parentSystem@link': {'href': 'http://localhost:8585/sensorhub/api/systems/blid74chqmses'},
                'sampledFeature@link': {'href': 'https://data.example.com/link/to/resource',
                                        'hreflang': 'en-US',
                                        'if': 'http://www.opengis.net/spec/spec-id/version',
                                        'rel': 'alternate',
                                        'rt': 'http://www.example.org/uri/of/concept',
                                        'title': 'Resource Name',
                                        'type': 'application/json',
                                        'uid': 'urn:x-org:resourceType:0001'},
                'uid': 'urn:osh:sensor:teststation:001'},
 'type': 'Feature'}
        geojson_headers = {'Content-Type': 'application/geo+json'}
        json_headers = {'Content-Type': 'application/json'}
        omjson_headers = {'Content-Type': 'application/om+json'}
        sml_component = {'definition': 'http://www.w3.org/ns/ssn/Sensor',
 'description': 'Test Component Description',
 'label': 'Test Component',
 'type': 'SimpleProcess',
 'uniqueId': 'urn:osh:sensor:testcomponent:001'}
        sml_headers = {'Content-Type': 'application/sml+json'}
        sml_procedure = {'definition': 'http://www.w3.org/ns/sosa/Procedure',
 'description': 'Test Procedure inserted via OWSLib',
 'id': '123456789',
 'label': 'Test Procedure - OWSLib',
 'type': 'SimpleProcess',
 'uniqueId': 'urn:osh:sensor:testprocedureows:001'}
        sml_procedure_test_system = {'definition': 'http://www.w3.org/ns/ssn/Sensor',
 'description': 'A Sensor created to test procedure/datastream creation',
 'label': 'Test Process/Datastream Sensor',
 'type': 'SimpleProcess',
 'uniqueId': 'urn:osh:sensor:testsensorwithcomponents:001'}
        sys_sml_def = {'definition': 'http://www.w3.org/ns/ssn/Sensor',
 'description': 'A Sensor created from an SML document',
 'label': 'Test SML Sensor - Created on its own',
 'type': 'SimpleProcess',
 'uniqueId': 'urn:osh:sensor:testsmlsensor:solo'}
        sys_sml_to_update = {'definition': 'http://www.w3.org/ns/ssn/Sensor',
 'description': 'A Sensor created from an SML document',
 'label': 'Test SML Sensor',
 'type': 'SimpleProcess',
 'uniqueId': 'urn:osh:sensor:testsmlsensor:001'}
        system_definitions = [{'definition': 'http://www.w3.org/ns/ssn/Sensor',
  'description': 'A Sensor created from an SML document',
  'label': 'Test SML Sensor',
  'type': 'SimpleProcess',
  'uniqueId': 'urn:osh:sensor:testsmlsensor:001'},
 {'definition': 'http://www.w3.org/ns/ssn/Sensor',
  'description': 'A Sensor created from an SML document',
  'label': 'Test SML Sensor #2',
  'type': 'SimpleProcess',
  'uniqueId': 'urn:osh:sensor:testsmlsensor:002'}]
        system_id  = 'blid74chqmses'
        weatherstation_id = '0s2lbn2n1bnc8'
owslib/ogcapi/connectedsystems.py:34: in __init__
    super().__init__(url, json_, timeout, headers, auth)
        __class__  = <class 'owslib.ogcapi.connectedsystems.Systems'>
        __doc__    = None
        auth       = <Authentication shared=False username=auto_test password=automated_tester24 cert=None verify=True auth_delegate=None>
        headers    = {'Content-Type': 'application/json'}
        json_      = None
        self       = <owslib.ogcapi.connectedsystems.Systems object at 0x7f0d8d2f5220>
        timeout    = 30
        url        = 'http://34.67.197.57:8585/sensorhub/api/'
owslib/ogcapi/connectedsystems.py:20: in __init__
    super().__init__(url, json_, timeout, headers, auth)
        __class__  = <class 'owslib.ogcapi.connectedsystems.ConnectedSystems'>
        __doc__    = 'Abstraction for OGC API - Common version 1.0'
        auth       = <Authentication shared=False username=auto_test password=automated_tester24 cert=None verify=True auth_delegate=None>
        headers    = {'Content-Type': 'application/json'}
        json_      = None
        self       = <owslib.ogcapi.connectedsystems.Systems object at 0x7f0d8d2f5220>
        timeout    = 30
        url        = 'http://34.67.197.57:8585/sensorhub/api/'
owslib/ogcapi/__init__.py:209: in __init__
    super().__init__(url, json_, timeout, headers, auth)
        __class__  = <class 'owslib.ogcapi.Collections'>
        __doc__    = 'Abstraction for OGC API - Common version 1.0'
        auth       = <Authentication shared=False username=auto_test password=automated_tester24 cert=None verify=True auth_delegate=None>
        headers    = {'Content-Type': 'application/json'}
        json_      = None
        self       = <owslib.ogcapi.connectedsystems.Systems object at 0x7f0d8d2f5220>
        timeout    = 30
        url        = 'http://34.67.197.57:8585/sensorhub/api/'
owslib/ogcapi/__init__.py:68: in __init__
    response = http_get(self.url, headers=self.headers, auth=self.auth).json()
        auth       = <Authentication shared=False username=auto_test password=automated_tester24 cert=None verify=True auth_delegate=None>
        headers    = {'Content-Type': 'application/json'}
        json_      = None
        self       = <owslib.ogcapi.connectedsystems.Systems object at 0x7f0d8d2f5220>
        timeout    = 30
        url        = 'http://34.67.197.57:8585/sensorhub/api/'
owslib/util.py:500: in http_get
    return requests.get(*args, **rkwargs)
        args       = ('http://34.67.197.57:8585/sensorhub/api/',)
        kwargs     = {'auth': <Authentication shared=False username=auto_test password=automated_tester24 cert=None verify=True auth_delegate=None>,
 'headers': {'Content-Type': 'application/json',
             'User-Agent': 'OWSLib 0.32.0 (https://owslib.readthedocs.io)'}}
        rkwargs    = {'auth': ('auto_test', 'automated_tester24'),
 'cert': None,
 'headers': {'Content-Type': 'application/json',
             'User-Agent': 'OWSLib 0.32.0 (https://owslib.readthedocs.io)'},
 'verify': True}
/usr/lib/python3.12/site-packages/requests/api.py:73: in get
    return request("get", url, params=params, **kwargs)
        kwargs     = {'auth': ('auto_test', 'automated_tester24'),
 'cert': None,
 'headers': {'Content-Type': 'application/json',
             'User-Agent': 'OWSLib 0.32.0 (https://owslib.readthedocs.io)'},
 'verify': True}
        params     = None
        url        = 'http://34.67.197.57:8585/sensorhub/api/'
/usr/lib/python3.12/site-packages/requests/api.py:59: in request
    return session.request(method=method, url=url, **kwargs)
        kwargs     = {'auth': ('auto_test', 'automated_tester24'),
 'cert': None,
 'headers': {'Content-Type': 'application/json',
             'User-Agent': 'OWSLib 0.32.0 (https://owslib.readthedocs.io)'},
 'params': None,
 'verify': True}
        method     = 'get'
        session    = <requests.sessions.Session object at 0x7f0d8dbed190>
        url        = 'http://34.67.197.57:8585/sensorhub/api/'
/usr/lib/python3.12/site-packages/requests/sessions.py:589: in request
    resp = self.send(prep, **send_kwargs)
        allow_redirects = True
        auth       = ('auto_test', 'automated_tester24')
        cert       = None
        cookies    = None
        data       = None
        files      = None
        headers    = {'Content-Type': 'application/json',
 'User-Agent': 'OWSLib 0.32.0 (https://owslib.readthedocs.io)'}
        hooks      = None
        json       = None
        method     = 'get'
        params     = None
        prep       = <PreparedRequest [GET]>
        proxies    = {}
        req        = <Request [GET]>
        self       = <requests.sessions.Session object at 0x7f0d8dbed190>
        send_kwargs = {'allow_redirects': True,
 'cert': None,
 'proxies': OrderedDict(),
 'stream': False,
 'timeout': None,
 'verify': True}
        settings   = {'cert': None, 'proxies': OrderedDict(), 'stream': False, 'verify': True}
        stream     = None
        timeout    = None
        url        = 'http://34.67.197.57:8585/sensorhub/api/'
        verify     = True
/usr/lib/python3.12/site-packages/requests/sessions.py:703: in send
    r = adapter.send(request, **kwargs)
        adapter    = <requests.adapters.HTTPAdapter object at 0x7f0d8dbed5b0>
        allow_redirects = True
        hooks      = {'response': []}
        kwargs     = {'cert': None,
 'proxies': OrderedDict(),
 'stream': False,
 'timeout': None,
 'verify': True}
        request    = <PreparedRequest [GET]>
        self       = <requests.sessions.Session object at 0x7f0d8dbed190>
        start      = 1729828780.8940225
        stream     = False
/usr/lib/python3.12/site-packages/requests/adapters.py:700: in send
    raise ConnectionError(e, request=request)
E   requests.exceptions.ConnectionError: HTTPConnectionPool(host='34.67.197.57', port=8585): Max retries exceeded with url: /sensorhub/api/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))
        cert       = None
        chunked    = False
        conn       = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f0d8dbed790>
        proxies    = OrderedDict()
        request    = <PreparedRequest [GET]>
        self       = <requests.adapters.HTTPAdapter object at 0x7f0d8dbed5b0>
        stream     = False
        timeout    = Timeout(connect=None, read=None, total=None)
        url        = '/sensorhub/api/'
        verify     = True
========================================================== warnings summary ===========================================================
tests/test_iso3_parsing.py:48
  /tmp/portage/dev-python/owslib-0.32.0/work/OWSLib-0.32.0/tests/test_iso3_parsing.py:48: PytestUnknownMarkWarning: Unknown pytest.mark.unit - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    pytestmark = pytest.mark.unit

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================= short test summary info =======================================================
ERROR tests/test_ogcapi_connectedsystems_osh.py - requests.exceptions.ConnectionError: HTTPConnectionPool(host='34.67.197.57', port=8585): Max retries exceeded with url: /sensorhub/api/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0d8dbed9a0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================= 71 deselected, 1 warning, 1 error in 1.41s ==============================================
geographika commented 1 month ago

@mgorny can you try annotating the failing tests with @pytest.mark.online and see if the test suite then passes?

mgorny commented 1 month ago

FWIU initializing OSHFixtures.systems_api is failing in global scope, therefore preventing the file from being imported, and possibly some more of the initializations below are going to fail as well. To fix this, I suppose the relevant bits would need to be initialized lazily or otherwise locally, and I'm not really sure how many tests would remain — or if any would.

mgorny commented 1 month ago

As I've suspected, all the *_api variable inits cause Internet accesses, and when I remove all of them, all the tests that aren't skipped — fail.

geographika commented 4 weeks ago

@mgorny - #952 runs the tests in offline mode (ignoring those that require network access). Do these changes get the test suite to pass on your setup?

mgorny commented 4 weeks ago

I'm afraid it doesn't. The test collection still fails on calls being made in the global scope. I think there are only two ways to prevent this from happening: either don't issue any network calls in global scope, or modify the pytest collect hook to skip the file entirely when Internet isn't available. I think the former should be easier, and could achieve very similar behavior by moving the class into a session-scope pytest fixture. I can try making a pull request if you'd like.

geographika commented 4 weeks ago

@mgorny - yes, a pull request would be appreciated. I guess the calls are made before the pytest plugin disables sockets. Attempting to create a GitHub Action and disabling network access did not seem to be a viable option (at least in terms of complexity and maintenance).

mgorny commented 3 weeks ago

I've opened https://github.com/geographika/OWSLib/pull/1 that modifies your PR to do the fixture approach.

geographika commented 2 weeks ago

Resolved with #952