Skip to content

Commit d402002

Browse files
committed
Correct api_version_text to not set a version for 0 and 1; remove test for versions higher than two, allow CDA to say version is not supported.
1 parent 841e0c2 commit d402002

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

cwms/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def api_version_text(api_version: int = 0, format: str = "") -> str:
163163
# XML returns from stdlib as text/xml, but CDA expects application/xml
164164
mimetype = "application/xml"
165165
# For present and future versions, append the version number if one is provided. Zero will not set a version.
166-
return mimetype + f";version={api_version}" if api_version else mimetype
166+
return mimetype if api_version in [0, 1] else mimetype + f";version={api_version}"
167167

168168

169169
def get(

tests/api_test.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,3 @@ def test_api_headers():
4848

4949
version = api_version_text(api_version=2)
5050
assert version == "application/json;version=2"
51-
52-
53-
def test_api_headers_invalid_version():
54-
"""An exception should be raised if the API version is not valid."""
55-
56-
with pytest.raises(InvalidVersion):
57-
version = api_version_text(api_version=3)

0 commit comments

Comments
 (0)