Skip to content

Commit

Permalink
MAINT: fix codestyle and add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz committed Oct 1, 2024
1 parent 7fe6884 commit 2026a5f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Deprecations and Removals
- Adding ``session`` kwarg to allow to pass a session along when turning
an Interface into a service via ``Interface.to_service``. [#590]

- Include port number if it is present in endpoint access URL. [#582]


1.5.2 (2024-05-22)
==================
Expand Down
3 changes: 2 additions & 1 deletion pyvo/dal/tests/test_tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,10 +791,11 @@ def test_get_udf(self, tapservice):
func = tapservice.get_tap_capability().get_adql().get_udf("IVO_hasword") # case insensitive!
assert func.form == "ivo_hasword(haystack TEXT, needle TEXT) -> INTEGER"


def test_get_endpoint_candidates():
# Directly instantiate the TAPService with a known base URL
svc = TAPService("http://astroweb.projects.phys.ucl.ac.uk:8000/tap")

# Check if the correct endpoint candidates are generated
expected_urls = [
"http://astroweb.projects.phys.ucl.ac.uk:8000/tap/capabilities",
Expand Down
13 changes: 5 additions & 8 deletions pyvo/dal/vosi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ def _get_endpoint_candidates(self, endpoint):
netloc = urlcomp.hostname
if urlcomp.port:
netloc += f':{urlcomp.port}'
curated_baseurl = '{}://{}{}'.format(urlcomp.scheme, netloc, urlcomp.path)
curated_baseurl = f'{urlcomp.scheme}://{netloc}{urlcomp.path}'

if not endpoint:
raise AttributeError('endpoint required')

return [
'{baseurl}/{endpoint}'.format(baseurl=curated_baseurl, endpoint=endpoint),
url_sibling(curated_baseurl, endpoint)
]

return [f'{curated_baseurl}/{endpoint}', url_sibling(curated_baseurl, endpoint)]

def _get_endpoint(self, endpoint):
for ep_url in self._get_endpoint_candidates(endpoint):
Expand All @@ -43,8 +40,7 @@ def _get_endpoint(self, endpoint):
except requests.RequestException:
continue
else:
raise DALServiceError(
f"No working {endpoint} endpoint provided")
raise DALServiceError(f"No working {endpoint} endpoint provided")

Check warning on line 43 in pyvo/dal/vosi.py

View check run for this annotation

Codecov / codecov/patch

pyvo/dal/vosi.py#L43

Added line #L43 was not covered by tests

return response.raw

Expand Down Expand Up @@ -144,6 +140,7 @@ class VOSITables:
Access to table names is like accessing dictionary keys. using iterator
syntax or `keys()`
"""

def __init__(self, vosi_tables, endpoint_url, *, session=None):
self._vosi_tables = vosi_tables
self._endpoint_url = endpoint_url
Expand Down

0 comments on commit 2026a5f

Please sign in to comment.