Skip to content

Commit 2b2a730

Browse files
committed
fix tests for mock protocol scheme and API subfolders
1 parent 84dc51d commit 2b2a730

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

aptly_api/tests/client.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ def test_instantiate(self) -> None:
2828
"Client (Aptly API Client) <http://test/>"
2929
)
3030

31-
def test_api_root_url(self) -> None:
32-
cl = AptlyClient("http://test////")
33-
self.assertEqual(cl.files.base_url, "http://test")
34-
3531
@requests_mock.Mocker(kw='rmock')
3632
def test_api_subdir_get(self, *, rmock: requests_mock.Mocker) -> None:
37-
cl = AptlyClient("http://test/basedir//")
38-
rmock.register_uri("GET", "mock://test/basedir/api", status_code=200, text='', reason="test")
39-
cl.files.do_get("/api/test")
33+
# register mock:// scheme with urllib.parse
34+
import urllib.parse
35+
urllib.parse.uses_netloc += ['mock']
36+
urllib.parse.uses_relative += ['mock']
37+
urllib.parse.uses_fragment += ['mock']
38+
urllib.parse.uses_params += ['mock']
39+
40+
cl = AptlyClient("mock://test/basedir/")
41+
rmock.get("mock://test/basedir/api/test", status_code=200, text='')
42+
cl.files.do_get("api/test")
4043
self.assertTrue(rmock.called)
4144

4245
def test_error_no_error(self) -> None:

0 commit comments

Comments
 (0)