MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / CavesMockServer

Class CavesMockServer

tests/mock_server.py:254–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252
253
254class CavesMockServer(MockServer):
255 def __init__(self,
256 caves_path=None, # type: Optional[str]
257 caves_url=None, # type: Optional[str]
258 caves_version=None, # type: Optional[str]
259 log_dir=None, # type: Optional[str]
260 log_filename=None, # type: Optional[str]
261 ):
262
263 super().__init__(log_dir=log_dir, log_filename=log_filename)
264
265 if caves_url is None:
266 caves_url = 'https://github.com/couchbaselabs/gocaves/releases/download'
267
268 self._caves_version = caves_version
269 if self._caves_version is None:
270 self._caves_version = 'v0.0.1-74'
271
272 self._build_caves_url(caves_url)
273 self._validate_caves_path(caves_path)
274
275 # @property
276 # def rest_port(self):
277 # return self._rest_port
278
279 # @property
280 # def connstr(self):
281 # return self._connstr
282
283 @property
284 def mock_type(self) -> MockServerType:
285 return MockServerType.GoCAVES
286
287 def _build_caves_url(self, url):
288
289 if sys.platform.startswith('linux'):
290 if platform.machine() == 'aarch64':
291 self._caves_url = f"{url}/{self._caves_version}/gocaves-linux-arm64"
292 else:
293 self._caves_url = f"{url}/{self._caves_version}/gocaves-linux-amd64"
294 elif sys.platform.startswith('darwin'):
295 if platform.machine() == 'arm64':
296 self._caves_url = f"{url}/{self._caves_version}/gocaves-macos-arm64"
297 else:
298 self._caves_url = f"{url}/{self._caves_version}/gocaves-macos"
299 elif sys.platform.startswith('win32'):
300 self._caves_url = f"{url}/{self._caves_version}/gocaves-windows.exe"
301 else:
302 raise MockServerException("Unrecognized platform for running GoCAVES mock server.")
303
304 def _validate_caves_path(self, caves_path=None):
305 if not (caves_path and not caves_path.isspace()):
306 if sys.platform.startswith('linux'):
307 caves_path = 'gocaves-linux-arm64' if platform.machine() == 'aarch64' else 'gocaves-linux-amd64'
308 elif sys.platform.startswith('darwin'):
309 caves_path = 'gocaves-macos-arm64' if platform.machine() == 'arm64' else 'gocaves-macos'
310 elif sys.platform.startswith('win32'):
311 caves_path = 'gocaves-windows.exe'

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected