Skip to content

Commit 8c8d250

Browse files
authored
Similar to syncgateway.py, created a replication url for CBL DBs (#179)
1 parent dc7e836 commit 8c8d250

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

client/src/cbltest/api/testserver.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from typing import cast
2+
from urllib.parse import urljoin
23

34
from opentelemetry.trace import get_tracer
45

56
from cbltest.api.database import Database
7+
from cbltest.assertions import _assert_not_null
68
from cbltest.globals import CBLPyTestGlobal
79
from cbltest.requests import RequestFactory, TestServerRequestType
810
from cbltest.responses import GetRootResponse
@@ -117,3 +119,13 @@ async def log(self, msg: str) -> None:
117119
TestServerRequestType.LOG, payload
118120
)
119121
await self.__request_factory.send_request(self.__index, request)
122+
123+
def replication_url(self, db_name: str, port: int):
124+
"""
125+
Returns the URL of the replication endpoint for this test server
126+
"""
127+
ws_scheme = "ws://" # For now not using secure
128+
129+
_assert_not_null(db_name, "db_name")
130+
replication_url = f"{ws_scheme}{self.url}:{port}"
131+
return urljoin(replication_url, db_name)

0 commit comments

Comments
 (0)