Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: (deps): Bump pytest from 7.2.0 to 8.3.3 in /ci #816

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest==7.2.0
pytest==8.3.3
netCDF4==1.7.2
coverage==7.6.4
vcrpy==5.1.0
4 changes: 2 additions & 2 deletions src/siphon/http_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ def query(self):

Returns
-------
valid : bool
Whether `query` is valid.
q : DataQuery
A new query object

"""
return DataQuery()
66 changes: 34 additions & 32 deletions tests/cdmr/test_cdmremote.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,44 @@
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
"""Test the CDM Remote HTTP API."""
import pytest

from siphon.cdmr.cdmremote import CDMRemote
from siphon.testing import get_recorder

recorder = get_recorder(__file__)


class TestCDMRmote:
"""Test the CDMRemote HTTP interface."""

def setup(self):
"""Set up all tests to point to the same dataset."""
self.cdmr = CDMRemote('http://localhost:8080/thredds/cdmremote/'
'nc4/nc4_pres_temp_4D.nc')

@recorder.use_cassette('cdmr_cdl')
def test_cdl(self):
"""Test getting a CDL document from CDMRemote."""
s = self.cdmr.fetch_cdl()
assert s

@recorder.use_cassette('cdmr_capabilities')
def test_capabilities(self):
"""Test getting a capabilities document from CDMRemote."""
s = self.cdmr.fetch_capabilities()
assert s

@recorder.use_cassette('cdmr_ncml')
def test_ncml(self):
"""Test getting an NCML document from CDMRemote."""
s = self.cdmr.fetch_ncml()
assert s

@recorder.use_cassette('cdmr_enable_compression')
def test_enable_compression(self):
"""Test turning on data compression for CDMRemote."""
self.cdmr.deflate = 4
d = self.cdmr.fetch_data(latitude=[slice(None)])
assert d
@pytest.fixture
def cdmr():
"""Set up all tests to point to the same dataset."""
return CDMRemote('http://localhost:8080/thredds/cdmremote/nc4/nc4_pres_temp_4D.nc')


@recorder.use_cassette('cdmr_cdl')
def test_cdl(cdmr):
"""Test getting a CDL document from CDMRemote."""
s = cdmr.fetch_cdl()
assert s


@recorder.use_cassette('cdmr_capabilities')
def test_capabilities(cdmr):
"""Test getting a capabilities document from CDMRemote."""
s = cdmr.fetch_capabilities()
assert s


@recorder.use_cassette('cdmr_ncml')
def test_ncml(cdmr):
"""Test getting an NCML document from CDMRemote."""
s = cdmr.fetch_ncml()
assert s


@recorder.use_cassette('cdmr_enable_compression')
def test_enable_compression(cdmr):
"""Test turning on data compression for CDMRemote."""
cdmr.deflate = 4
d = cdmr.fetch_data(latitude=[slice(None)])
assert d
67 changes: 35 additions & 32 deletions tests/cdmr/test_cdmremotefeature.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,44 @@

from datetime import datetime

import pytest

from siphon.cdmr.cdmremotefeature import CDMRemoteFeature
from siphon.testing import get_recorder

recorder = get_recorder(__file__)


class TestCDMRemoteFeature:
"""Test the CDMRemoteFeature HTTP interface."""

@recorder.use_cassette('cdmrf_header')
def setup(self):
"""Set up all tests to point to the same dataset."""
self.cdmrf = CDMRemoteFeature('http://localhost:8080/thredds/cdmrfeature/grid/'
'test/HRRR_CONUS_2p5km_20160309_1600.grib2')

@recorder.use_cassette('cdmrf_feature_type')
def test_feature_type(self):
"""Test getting feature type from CDMRemoteFeature."""
s = self.cdmrf.fetch_feature_type()
assert s == b'GRID'

@recorder.use_cassette('cdmrf_data')
def test_data(self):
"""Test getting data from CDMRemoteFeature."""
q = self.cdmrf.query()
q.variables('Wind_speed_height_above_ground_1_Hour_Maximum')
q.time(datetime(2016, 3, 9, 16))
q.lonlat_box(-106, -105, 39, 40)
s = self.cdmrf.get_data(q)
assert s

@recorder.use_cassette('cdmrf_coords')
def test_coords(self):
"""Test getting coordinate data for CDMRemoteFeature."""
q = self.cdmrf.query()
q.variables('x')
d = self.cdmrf.fetch_coords(q)
assert d
@pytest.fixture
@recorder.use_cassette('cdmrf_header')
def cdmrf():
"""Set up all tests to point to the same dataset."""
return CDMRemoteFeature('http://localhost:8080/thredds/cdmrfeature/grid/'
'test/HRRR_CONUS_2p5km_20160309_1600.grib2')


@recorder.use_cassette('cdmrf_feature_type')
def test_feature_type(cdmrf):
"""Test getting feature type from CDMRemoteFeature."""
s = cdmrf.fetch_feature_type()
assert s == b'GRID'


@recorder.use_cassette('cdmrf_data')
def test_data(cdmrf):
"""Test getting data from CDMRemoteFeature."""
q = cdmrf.query()
q.variables('Wind_speed_height_above_ground_1_Hour_Maximum')
q.time(datetime(2016, 3, 9, 16))
q.lonlat_box(-106, -105, 39, 40)
s = cdmrf.get_data(q)
assert s


@recorder.use_cassette('cdmrf_coords')
def test_coords(cdmrf):
"""Test getting coordinate data for CDMRemoteFeature."""
q = cdmrf.query()
q.variables('x')
d = cdmrf.fetch_coords(q)
assert d
88 changes: 46 additions & 42 deletions tests/test_http_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,45 +169,49 @@ def test_http_error_no_header():
endpoint.get_query(query)


class TestEndPoint:
"""Test the HTTPEndPoint."""

def setup(self):
"""Set up tests to point to a common server, api, and end point."""
self.server = 'http://thredds.ucar.edu/'
self.api = 'thredds/metadata/grib/NCEP/GFS/Global_0p5deg/TwoD'
self.endpoint = HTTPEndPoint(self.server + self.api)

def test_basic(self):
"""Test creating a basic query and validating it."""
q = self.endpoint.query()
q.all_times()
assert self.endpoint.validate_query(q), 'Invalid query.'

@recorder.use_cassette('gfs-metadata-map')
def test_trailing_slash(self):
"""Test setting up and end point with a url with a trailing slash."""
endpoint = HTTPEndPoint(self.server + self.api + '/')
q = endpoint.query()
q.add_query_parameter(metadata='variableMap')
resp = endpoint.get_query(q)
assert resp.content

@recorder.use_cassette('gfs-metadata-map')
def test_query(self):
"""Test getting a query."""
q = self.endpoint.query()
q.add_query_parameter(metadata='variableMap')
resp = self.endpoint.get_query(q)
assert resp.content

@recorder.use_cassette('gfs-metadata-map-bad')
def test_get_error(self):
"""Test that getting a bad path raises an error."""
with pytest.raises(HTTPError):
self.endpoint.get_path('')

def test_url_path(self):
"""Test forming a url path from the end point."""
path = self.endpoint.url_path('foobar.html')
assert path == self.server + self.api + '/foobar.html'
@pytest.fixture
def endpoint():
"""Set up tests to point to a common server, api, and end point."""
return HTTPEndPoint('http://thredds.ucar.edu/'
'thredds/metadata/grib/NCEP/GFS/Global_0p5deg/TwoD')


def test_basic(endpoint):
"""Test creating a basic query and validating it."""
q = endpoint.query()
q.all_times()
assert endpoint.validate_query(q)


@recorder.use_cassette('gfs-metadata-map')
def test_trailing_slash():
"""Test setting up and end point with a url with a trailing slash."""
endpoint = HTTPEndPoint('http://thredds.ucar.edu/' +
'thredds/metadata/grib/NCEP/GFS/Global_0p5deg/TwoD' + '/')
q = endpoint.query()
q.add_query_parameter(metadata='variableMap')
resp = endpoint.get_query(q)
assert resp.content


@recorder.use_cassette('gfs-metadata-map')
def test_query(endpoint):
"""Test getting a query."""
q = endpoint.query()
q.add_query_parameter(metadata='variableMap')
resp = endpoint.get_query(q)
assert resp.content


@recorder.use_cassette('gfs-metadata-map-bad')
def test_get_error(endpoint):
"""Test that getting a bad path raises an error."""
with pytest.raises(HTTPError):
endpoint.get_path('')


def test_url_path(endpoint):
"""Test forming a url path from the end point."""
path = endpoint.url_path('foobar.html')
assert path == ('http://thredds.ucar.edu/thredds/metadata/grib/NCEP/GFS/Global_0p5deg/TwoD'
'/foobar.html')
Loading