feat: add packages and content packages #303
GitHub Actions / integration-test-results
failed
Nov 8, 2024 in 0s
2 fail, 38 pass in 6m 32s
Annotations
Check warning on line 0 in integration.tests.posit.connect.test_packages.TestPackages
github-actions / integration-test-results
1 out of 20 runs failed: test (integration.tests.posit.connect.test_packages.TestPackages)
artifacts/preview - Integration Test Report/preview.xml [took 1s]
Raw output
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://connect:3939/__api__/v1/content/80efbbe5-1bff-4750-9c11-9798649324fe/packages
self = <Response [404]>, kwargs = {}
def json(self, **kwargs):
r"""Returns the json-encoded content of a response, if any.
:param \*\*kwargs: Optional arguments that ``json.loads`` takes.
:raises requests.exceptions.JSONDecodeError: If the response body does not
contain valid json.
"""
if not self.encoding and self.content and len(self.content) > 3:
# No encoding set. JSON RFC 4627 section 3 states we should expect
# UTF-8, -16 or -32. Detect which one to use; If the detection or
# decoding fails, fall back to `self.text` (using charset_normalizer to make
# a best guess).
encoding = guess_json_utf(self.content)
if encoding is not None:
try:
return complexjson.loads(self.content.decode(encoding), **kwargs)
except UnicodeDecodeError:
# Wrong UTF codec detected; usually because it's not UTF-8
# but some other 8-bit codec. This is an RFC violation,
# and the server didn't bother to tell us what codec *was*
# used.
pass
except JSONDecodeError as e:
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
try:
> return complexjson.loads(self.text, **kwargs)
../.venv/lib/python3.13/site-packages/requests/models.py:974:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.13/json/__init__.py:346: in loads
return _default_decoder.decode(s)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <json.decoder.JSONDecoder object at 0x7f7e89f61400>
s = '404 page not found'
_w = <built-in method match of re.Pattern object at 0x7f7e89fd3b90>
def decode(self, s, _w=WHITESPACE.match):
"""Return the Python representation of ``s`` (a ``str`` instance
containing a JSON document).
"""
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
end = _w(s, end).end()
if end != len(s):
> raise JSONDecodeError("Extra data", s, end)
E json.decoder.JSONDecodeError: Extra data: line 1 column 5 (char 4)
/usr/local/lib/python3.13/json/decoder.py:347: JSONDecodeError
During handling of the above exception, another exception occurred:
response = <Response [404]>, args = ()
kwargs = {'cert': None, 'proxies': OrderedDict(), 'stream': False, 'timeout': None, ...}
def handle_errors(response: Response, *args, **kwargs) -> Response:
if response.status_code >= 400:
try:
> data = response.json()
../src/posit/connect/hooks.py:12:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [404]>, kwargs = {}
def json(self, **kwargs):
r"""Returns the json-encoded content of a response, if any.
:param \*\*kwargs: Optional arguments that ``json.loads`` takes.
:raises requests.exceptions.JSONDecodeError: If the response body does not
contain valid json.
"""
if not self.encoding and self.content and len(self.content) > 3:
# No encoding set. JSON RFC 4627 section 3 states we should expect
# UTF-8, -16 or -32. Detect which one to use; If the detection or
# decoding fails, fall back to `self.text` (using charset_normalizer to make
# a best guess).
encoding = guess_json_utf(self.content)
if encoding is not None:
try:
return complexjson.loads(self.content.decode(encoding), **kwargs)
except UnicodeDecodeError:
# Wrong UTF codec detected; usually because it's not UTF-8
# but some other 8-bit codec. This is an RFC violation,
# and the server didn't bother to tell us what codec *was*
# used.
pass
except JSONDecodeError as e:
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
try:
return complexjson.loads(self.text, **kwargs)
except JSONDecodeError as e:
# Catch JSON-related errors and raise as requests.JSONDecodeError
# This aliases json.JSONDecodeError and simplejson.JSONDecodeError
> raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
E requests.exceptions.JSONDecodeError: Extra data: line 1 column 5 (char 4)
../.venv/lib/python3.13/site-packages/requests/models.py:978: JSONDecodeError
During handling of the above exception, another exception occurred:
self = <connect.test_packages.TestPackages object at 0x7f7e88ba02d0>
def test(self):
# assert self.client.packages
> assert self.content.packages
tests/posit/connect/test_packages.py:32:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../src/posit/connect/resources.py:173: in __len__
return len(self._data)
../src/posit/connect/resources.py:157: in _data
self._cache = self.fetch()
../src/posit/connect/packages.py:38: in fetch
return super().fetch(**conditions)
../src/posit/connect/resources.py:121: in fetch
response = self._ctx.session.get(endpoint, params=conditions)
../.venv/lib/python3.13/site-packages/requests/sessions.py:602: in get
return self.request("GET", url, **kwargs)
../.venv/lib/python3.13/site-packages/requests/sessions.py:589: in request
resp = self.send(prep, **send_kwargs)
../.venv/lib/python3.13/site-packages/requests/sessions.py:710: in send
r = dispatch_hook("response", hooks, r, **kwargs)
../.venv/lib/python3.13/site-packages/requests/hooks.py:30: in dispatch_hook
_hook_data = hook(hook_data, **kwargs)
../src/posit/connect/hooks.py:21: in handle_errors
response.raise_for_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [404]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://connect:3939/__api__/v1/content/80efbbe5-1bff-4750-9c11-9798649324fe/packages
../.venv/lib/python3.13/site-packages/requests/models.py:1024: HTTPError
Check warning on line 0 in integration.tests.posit.connect.test_packages.TestPackages
github-actions / integration-test-results
1 out of 20 runs failed: test_find_by (integration.tests.posit.connect.test_packages.TestPackages)
artifacts/preview - Integration Test Report/preview.xml [took 0s]
Raw output
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://connect:3939/__api__/v1/content/80efbbe5-1bff-4750-9c11-9798649324fe/packages
self = <Response [404]>, kwargs = {}
def json(self, **kwargs):
r"""Returns the json-encoded content of a response, if any.
:param \*\*kwargs: Optional arguments that ``json.loads`` takes.
:raises requests.exceptions.JSONDecodeError: If the response body does not
contain valid json.
"""
if not self.encoding and self.content and len(self.content) > 3:
# No encoding set. JSON RFC 4627 section 3 states we should expect
# UTF-8, -16 or -32. Detect which one to use; If the detection or
# decoding fails, fall back to `self.text` (using charset_normalizer to make
# a best guess).
encoding = guess_json_utf(self.content)
if encoding is not None:
try:
return complexjson.loads(self.content.decode(encoding), **kwargs)
except UnicodeDecodeError:
# Wrong UTF codec detected; usually because it's not UTF-8
# but some other 8-bit codec. This is an RFC violation,
# and the server didn't bother to tell us what codec *was*
# used.
pass
except JSONDecodeError as e:
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
try:
> return complexjson.loads(self.text, **kwargs)
../.venv/lib/python3.13/site-packages/requests/models.py:974:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.13/json/__init__.py:346: in loads
return _default_decoder.decode(s)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <json.decoder.JSONDecoder object at 0x7f7e89f61400>
s = '404 page not found'
_w = <built-in method match of re.Pattern object at 0x7f7e89fd3b90>
def decode(self, s, _w=WHITESPACE.match):
"""Return the Python representation of ``s`` (a ``str`` instance
containing a JSON document).
"""
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
end = _w(s, end).end()
if end != len(s):
> raise JSONDecodeError("Extra data", s, end)
E json.decoder.JSONDecodeError: Extra data: line 1 column 5 (char 4)
/usr/local/lib/python3.13/json/decoder.py:347: JSONDecodeError
During handling of the above exception, another exception occurred:
response = <Response [404]>, args = ()
kwargs = {'cert': None, 'proxies': OrderedDict(), 'stream': False, 'timeout': None, ...}
def handle_errors(response: Response, *args, **kwargs) -> Response:
if response.status_code >= 400:
try:
> data = response.json()
../src/posit/connect/hooks.py:12:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [404]>, kwargs = {}
def json(self, **kwargs):
r"""Returns the json-encoded content of a response, if any.
:param \*\*kwargs: Optional arguments that ``json.loads`` takes.
:raises requests.exceptions.JSONDecodeError: If the response body does not
contain valid json.
"""
if not self.encoding and self.content and len(self.content) > 3:
# No encoding set. JSON RFC 4627 section 3 states we should expect
# UTF-8, -16 or -32. Detect which one to use; If the detection or
# decoding fails, fall back to `self.text` (using charset_normalizer to make
# a best guess).
encoding = guess_json_utf(self.content)
if encoding is not None:
try:
return complexjson.loads(self.content.decode(encoding), **kwargs)
except UnicodeDecodeError:
# Wrong UTF codec detected; usually because it's not UTF-8
# but some other 8-bit codec. This is an RFC violation,
# and the server didn't bother to tell us what codec *was*
# used.
pass
except JSONDecodeError as e:
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
try:
return complexjson.loads(self.text, **kwargs)
except JSONDecodeError as e:
# Catch JSON-related errors and raise as requests.JSONDecodeError
# This aliases json.JSONDecodeError and simplejson.JSONDecodeError
> raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
E requests.exceptions.JSONDecodeError: Extra data: line 1 column 5 (char 4)
../.venv/lib/python3.13/site-packages/requests/models.py:978: JSONDecodeError
During handling of the above exception, another exception occurred:
self = <connect.test_packages.TestPackages object at 0x7f7e88ba0410>
def test_find_by(self):
# package = self.client.packages.find_by(name="flask")
# assert package
# assert package["name"] == "flask"
> package = self.content.packages.find_by(name="flask")
tests/posit/connect/test_packages.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../src/posit/connect/packages.py:94: in find_by
return super().find_by(**conditions)
../src/posit/connect/resources.py:223: in find_by
collection = self.fetch()
../src/posit/connect/packages.py:38: in fetch
return super().fetch(**conditions)
../src/posit/connect/resources.py:121: in fetch
response = self._ctx.session.get(endpoint, params=conditions)
../.venv/lib/python3.13/site-packages/requests/sessions.py:602: in get
return self.request("GET", url, **kwargs)
../.venv/lib/python3.13/site-packages/requests/sessions.py:589: in request
resp = self.send(prep, **send_kwargs)
../.venv/lib/python3.13/site-packages/requests/sessions.py:710: in send
r = dispatch_hook("response", hooks, r, **kwargs)
../.venv/lib/python3.13/site-packages/requests/hooks.py:30: in dispatch_hook
_hook_data = hook(hook_data, **kwargs)
../src/posit/connect/hooks.py:21: in handle_errors
response.raise_for_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [404]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://connect:3939/__api__/v1/content/80efbbe5-1bff-4750-9c11-9798649324fe/packages
../.venv/lib/python3.13/site-packages/requests/models.py:1024: HTTPError
Loading