Skip to content

refactor: Use new duck typing for content item .repository methods #529

refactor: Use new duck typing for content item .repository methods

refactor: Use new duck typing for content item .repository methods #529

GitHub Actions / integration-test-results failed Dec 16, 2024 in 0s

5 errors, 1 fail, 48 pass in 11m 40s

   21 files   21 suites   11m 40s ⏱️
   54 tests  48 ✅   0 💤 1 ❌ 5 🔥
1 138 runs  965 ✅ 167 💤 1 ❌ 5 🔥

Results for commit d319c5b.

Annotations

Check failure on line 0 in integration.tests.posit.connect.test_jobs.TestJobs

See this annotation in the file changed.

@github-actions github-actions / integration-test-results

1 out of 21 runs with error: test_find_by (integration.tests.posit.connect.test_jobs.TestJobs)

artifacts/2023.12.0 - Integration Test Report/2023.12.0.xml [took 4s]
Raw output
failed on teardown with "requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://connect:3939/__api__/v1/content/a9928fd6-4040-44ff-87b4-3821ef1479dd"
self = <Response [500]>, 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)
/usr/local/lib/python3.13/json/decoder.py:345: in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <json.decoder.JSONDecoder object at 0x7f49d59fcd70>, s = '', idx = 0

    def raw_decode(self, s, idx=0):
        """Decode a JSON document from ``s`` (a ``str`` beginning with
        a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.
    
        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.
    
        """
        try:
            obj, end = self.scan_once(s, idx)
        except StopIteration as err:
>           raise JSONDecodeError("Expecting value", s, err.value) from None
E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

/usr/local/lib/python3.13/json/decoder.py:363: JSONDecodeError

During handling of the above exception, another exception occurred:

response = <Response [500]>, request_hook_args = ()
request_hook_kwargs = {'cert': None, 'proxies': OrderedDict(), 'stream': False, 'timeout': None, ...}

    def handle_errors(
        response: Response,
        # Arguments for the hook callback signature
        *request_hook_args,  # noqa: ARG001
        **request_hook_kwargs,  # noqa: ARG001
    ) -> Response:
        if response.status_code >= 400:
            try:
>               data = response.json()

../src/posit/connect/hooks.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Response [500]>, 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: Expecting value: line 1 column 1 (char 0)

../.venv/lib/python3.13/site-packages/requests/models.py:978: JSONDecodeError

During handling of the above exception, another exception occurred:

cls = <class 'connect.test_jobs.TestJobs'>

    @classmethod
    def teardown_class(cls):
>       cls.content.delete()

tests/posit/connect/test_jobs.py:23: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../src/posit/connect/content.py:149: in delete
    self._ctx.client.delete(path)
../src/posit/connect/client.py:468: in delete
    return self.session.delete(url, **kwargs)
../.venv/lib/python3.13/site-packages/requests/sessions.py:671: in delete
    return self.request("DELETE", 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:26: in handle_errors
    response.raise_for_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Response [500]>

    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: 500 Server Error: Internal Server Error for url: http://connect:3939/__api__/v1/content/a9928fd6-4040-44ff-87b4-3821ef1479dd

../.venv/lib/python3.13/site-packages/requests/models.py:1024: HTTPError

Check failure on line 0 in integration.tests.posit.connect.test_system.TestSystem

See this annotation in the file changed.

@github-actions github-actions / integration-test-results

1 out of 21 runs with error: test_runtime_caches (integration.tests.posit.connect.test_system.TestSystem)

artifacts/2023.12.0 - Integration Test Report/2023.12.0.xml [took 0s]
Raw output
failed on setup with "AssertionError: assert 1 == 0
 +  where 1 = count()
 +    where count = <posit.connect.content.Content object at 0x7f49d4767800>.count
 +      where <posit.connect.content.Content object at 0x7f49d4767800> = <posit.connect.client.Client object at 0x7f49d4748d50>.content
 +        where <posit.connect.client.Client object at 0x7f49d4748d50> = <class 'connect.test_system.TestSystem'>.client"
cls = <class 'connect.test_system.TestSystem'>

    @classmethod
    def setup_class(cls):
        cls.client = Client()
>       assert cls.client.content.count() == 0
E       AssertionError: assert 1 == 0
E        +  where 1 = count()
E        +    where count = <posit.connect.content.Content object at 0x7f49d4767800>.count
E        +      where <posit.connect.content.Content object at 0x7f49d4767800> = <posit.connect.client.Client object at 0x7f49d4748d50>.content
E        +        where <posit.connect.client.Client object at 0x7f49d4748d50> = <class 'connect.test_system.TestSystem'>.client

tests/posit/connect/test_system.py:23: AssertionError

Check failure on line 0 in integration.tests.posit.connect.test_tags.TestTags

See this annotation in the file changed.

@github-actions github-actions / integration-test-results

1 out of 21 runs with error: test_tag_content_items (integration.tests.posit.connect.test_tags.TestTags)

artifacts/2023.12.0 - Integration Test Report/2023.12.0.xml [took 2s]
Raw output
failed on teardown with "AssertionError: assert 1 == 0
 +  where 1 = len([{'guid': 'a9928fd6-4040-44ff-87b4-3821ef1479dd', 'name': 'example-quarto-minimal', 'title': None, 'description': '', ...board_url': 'http://connect:3939/connect/#/apps/a9928fd6-4040-44ff-87b4-3821ef1479dd', 'app_role': 'owner', 'id': '6'}])
 +    where [{'guid': 'a9928fd6-4040-44ff-87b4-3821ef1479dd', 'name': 'example-quarto-minimal', 'title': None, 'description': '', ...board_url': 'http://connect:3939/connect/#/apps/a9928fd6-4040-44ff-87b4-3821ef1479dd', 'app_role': 'owner', 'id': '6'}] = find()
 +      where find = <posit.connect.content.Content object at 0x7f49d4832f00>.find
 +        where <posit.connect.content.Content object at 0x7f49d4832f00> = <posit.connect.client.Client object at 0x7f49d4755310>.content
 +          where <posit.connect.client.Client object at 0x7f49d4755310> = <class 'connect.test_tags.TestTags'>.client"
cls = <class 'connect.test_tags.TestTags'>

    @classmethod
    def teardown_class(cls):
        assert len(cls.client.tags.find()) == 0
        cls.contentA.delete()
        cls.contentB.delete()
        cls.contentC.delete()
>       assert len(cls.client.content.find()) == 0
E       AssertionError: assert 1 == 0
E        +  where 1 = len([{'guid': 'a9928fd6-4040-44ff-87b4-3821ef1479dd', 'name': 'example-quarto-minimal', 'title': None, 'description': '', ...board_url': 'http://connect:3939/connect/#/apps/a9928fd6-4040-44ff-87b4-3821ef1479dd', 'app_role': 'owner', 'id': '6'}])
E        +    where [{'guid': 'a9928fd6-4040-44ff-87b4-3821ef1479dd', 'name': 'example-quarto-minimal', 'title': None, 'description': '', ...board_url': 'http://connect:3939/connect/#/apps/a9928fd6-4040-44ff-87b4-3821ef1479dd', 'app_role': 'owner', 'id': '6'}] = find()
E        +      where find = <posit.connect.content.Content object at 0x7f49d4832f00>.find
E        +        where <posit.connect.content.Content object at 0x7f49d4832f00> = <posit.connect.client.Client object at 0x7f49d4755310>.content
E        +          where <posit.connect.client.Client object at 0x7f49d4755310> = <class 'connect.test_tags.TestTags'>.client

tests/posit/connect/test_tags.py:18: AssertionError

Check warning on line 0 in integration.tests.posit.connect.test_users.TestUserContent

See this annotation in the file changed.

@github-actions github-actions / integration-test-results

1 out of 21 runs failed: test_count (integration.tests.posit.connect.test_users.TestUserContent)

artifacts/2023.12.0 - Integration Test Report/2023.12.0.xml [took 0s]
Raw output
AssertionError: assert 2 == 1
 +  where 2 = count()
 +    where count = <posit.connect.content.Content object at 0x7f49d45e6350>.count
 +      where <posit.connect.content.Content object at 0x7f49d45e6350> = {'email': '', 'username': '__bootstrap_admin__', 'first_name': '', 'last_name': '', 'user_role': 'administrator', 'cre...tive_time': '2024-12-16T22:22:42Z', 'confirmed': True, 'locked': False, 'guid': 'd634023e-8a67-4d7e-bd30-389dc7dbb4fd'}.content
 +        where {'email': '', 'username': '__bootstrap_admin__', 'first_name': '', 'last_name': '', 'user_role': 'administrator', 'cre...tive_time': '2024-12-16T22:22:42Z', 'confirmed': True, 'locked': False, 'guid': 'd634023e-8a67-4d7e-bd30-389dc7dbb4fd'} = <connect.test_users.TestUserContent object at 0x7f49d4725a90>.me
self = <connect.test_users.TestUserContent object at 0x7f49d4725a90>

    def test_count(self):
>       assert self.me.content.count() == 1
E       AssertionError: assert 2 == 1
E        +  where 2 = count()
E        +    where count = <posit.connect.content.Content object at 0x7f49d45e6350>.count
E        +      where <posit.connect.content.Content object at 0x7f49d45e6350> = {'email': '', 'username': '__bootstrap_admin__', 'first_name': '', 'last_name': '', 'user_role': 'administrator', 'cre...tive_time': '2024-12-16T22:22:42Z', 'confirmed': True, 'locked': False, 'guid': 'd634023e-8a67-4d7e-bd30-389dc7dbb4fd'}.content
E        +        where {'email': '', 'username': '__bootstrap_admin__', 'first_name': '', 'last_name': '', 'user_role': 'administrator', 'cre...tive_time': '2024-12-16T22:22:42Z', 'confirmed': True, 'locked': False, 'guid': 'd634023e-8a67-4d7e-bd30-389dc7dbb4fd'} = <connect.test_users.TestUserContent object at 0x7f49d4725a90>.me

tests/posit/connect/test_users.py:116: AssertionError

Check failure on line 0 in integration.tests.posit.connect.test_users.TestUserContent

See this annotation in the file changed.

@github-actions github-actions / integration-test-results

1 out of 21 runs with error: test_multiple_users (integration.tests.posit.connect.test_users.TestUserContent)

artifacts/2023.12.0 - Integration Test Report/2023.12.0.xml [took 0s]
Raw output
failed on teardown with "AssertionError: assert 1 == 0
 +  where 1 = count()
 +    where count = <posit.connect.content.Content object at 0x7f49d46d5430>.count
 +      where <posit.connect.content.Content object at 0x7f49d46d5430> = {'email': '', 'username': '__bootstrap_admin__', 'first_name': '', 'last_name': '', 'user_role': 'administrator', 'cre...tive_time': '2024-12-16T22:22:42Z', 'confirmed': True, 'locked': False, 'guid': 'd634023e-8a67-4d7e-bd30-389dc7dbb4fd'}.content
 +        where {'email': '', 'username': '__bootstrap_admin__', 'first_name': '', 'last_name': '', 'user_role': 'administrator', 'cre...tive_time': '2024-12-16T22:22:42Z', 'confirmed': True, 'locked': False, 'guid': 'd634023e-8a67-4d7e-bd30-389dc7dbb4fd'} = <class 'connect.test_users.TestUserContent'>.me"
cls = <class 'connect.test_users.TestUserContent'>

    @classmethod
    def teardown_class(cls):
        assert cls.content.delete() is None
>       assert cls.me.content.count() == 0
E       AssertionError: assert 1 == 0
E        +  where 1 = count()
E        +    where count = <posit.connect.content.Content object at 0x7f49d46d5430>.count
E        +      where <posit.connect.content.Content object at 0x7f49d46d5430> = {'email': '', 'username': '__bootstrap_admin__', 'first_name': '', 'last_name': '', 'user_role': 'administrator', 'cre...tive_time': '2024-12-16T22:22:42Z', 'confirmed': True, 'locked': False, 'guid': 'd634023e-8a67-4d7e-bd30-389dc7dbb4fd'}.content
E        +        where {'email': '', 'username': '__bootstrap_admin__', 'first_name': '', 'last_name': '', 'user_role': 'administrator', 'cre...tive_time': '2024-12-16T22:22:42Z', 'confirmed': True, 'locked': False, 'guid': 'd634023e-8a67-4d7e-bd30-389dc7dbb4fd'} = <class 'connect.test_users.TestUserContent'>.me

tests/posit/connect/test_users.py:113: AssertionError

Check failure on line 0 in integration.tests.posit.connect.test_vanities.TestVanities

See this annotation in the file changed.

@github-actions github-actions / integration-test-results

1 out of 21 runs with error: test_destroy (integration.tests.posit.connect.test_vanities.TestVanities)

artifacts/2023.12.0 - Integration Test Report/2023.12.0.xml [took 0s]
Raw output
failed on teardown with "AssertionError: assert 1 == 0
 +  where 1 = count()
 +    where count = <posit.connect.content.Content object at 0x7f49d46d7710>.count
 +      where <posit.connect.content.Content object at 0x7f49d46d7710> = <posit.connect.client.Client object at 0x7f49d46a57f0>.content
 +        where <posit.connect.client.Client object at 0x7f49d46a57f0> = <class 'connect.test_vanities.TestVanities'>.client"
cls = <class 'connect.test_vanities.TestVanities'>

    @classmethod
    def teardown_class(cls):
>       assert cls.client.content.count() == 0
E       AssertionError: assert 1 == 0
E        +  where 1 = count()
E        +    where count = <posit.connect.content.Content object at 0x7f49d46d7710>.count
E        +      where <posit.connect.content.Content object at 0x7f49d46d7710> = <posit.connect.client.Client object at 0x7f49d46a57f0>.content
E        +        where <posit.connect.client.Client object at 0x7f49d46a57f0> = <class 'connect.test_vanities.TestVanities'>.client

tests/posit/connect/test_vanities.py:11: AssertionError