Commit 97672aaa authored by Jan Reimes's avatar Jan Reimes
Browse files

test(portal): mock credential resolution in PortalClient tests

* Patch resolve_credentials to return None in tests
* Ensure client initialization and authentication handle missing credentials
* Update tests for fetch_tdoc_metadata to reflect credential checks
parent acf4b75f
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ class TestPortalClientInit:

    def test_init_without_credentials(self) -> None:
        """Client can be created without credentials for URL extraction."""
        with patch("tdoc_crawler.clients.portal.resolve_credentials", return_value=None):
            client = PortalClient()
            assert client.credentials is None
            assert client.timeout == 30
@@ -139,6 +140,7 @@ class TestPortalClientAuthenticate:

    def test_authenticate_requires_credentials(self) -> None:
        """Authentication fails without credentials."""
        with patch("tdoc_crawler.clients.portal.resolve_credentials", return_value=None):
            client = PortalClient()
            with pytest.raises(ValueError):
                client.authenticate()
@@ -191,6 +193,7 @@ class TestPortalClientFetchTdocMetadata:

    def test_fetch_requires_authentication(self) -> None:
        """Fetching fails without credentials."""
        with patch("tdoc_crawler.clients.portal.resolve_credentials", return_value=None):
            client = PortalClient()
            with pytest.raises(ValueError):
                client.fetch_tdoc_metadata("S4-251364")