Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_stop_notebook_without_commit(self):
httpretty.register_uri(
httpretty.POST,
BaseApiHandler.build_url(
self.api_config.base_url,
"/",
"username",
"project_name",
"notebook",
"stop",
),
content_type="application/json",
status=200,
)
result = self.api_handler.stop_notebook(
"username", "project_name", commit=False
)
assert result.status_code == 200
# Async
def test_get_platform_version(self):
obj = PlatformVersionConfig(latest_version="1.0", min_version="0.5").to_dict()
httpretty.register_uri(
httpretty.GET,
BaseApiHandler.build_url(
self.api_config.base_url, "/versions/", "platform"
),
body=json.dumps(obj),
content_type="application/json",
status=200,
)
# Schema response
result = self.api_handler.get_platform_version()
assert result.to_dict() == obj
# Raw response
self.set_raw_response()
result = self.api_handler.get_platform_version()
assert result == obj
def test_stop_experiment(self):
httpretty.register_uri(
httpretty.POST,
BaseApiHandler.build_url(
self.api_config.base_url,
"/",
"username",
"project_name",
"experiments",
1,
"stop",
),
content_type="application/json",
status=200,
)
result = self.api_handler.stop("username", "project_name", 1)
assert result.status_code == 200
# Async
self.assert_async_call(
def test_unbookmark_experiment(self):
httpretty.register_uri(
httpretty.DELETE,
BaseApiHandler.build_url(
self.api_config.base_url,
"/",
"username",
"project_name",
"experiments",
1,
"unbookmark",
),
content_type="application/json",
status=200,
)
result = self.api_handler.unbookmark("username", "project_name", 1)
assert result.status_code == 200
# Async
self.assert_async_call(
def test_get_cli_version(self):
obj = CliVersionConfig(latest_version="1.0", min_version="0.5").to_dict()
httpretty.register_uri(
httpretty.GET,
BaseApiHandler.build_url(self.api_config.base_url, "/versions/", "cli"),
body=json.dumps(obj),
content_type="application/json",
status=200,
)
# Schema response
result = self.api_handler.get_cli_version()
assert result.to_dict() == obj
# Raw response
self.set_raw_response()
result = self.api_handler.get_cli_version()
assert result == obj
def test_restart_experiment(self):
exp = ExperimentConfig().to_dict()
httpretty.register_uri(
httpretty.POST,
BaseApiHandler.build_url(
self.api_config.base_url,
"/",
"username",
"project_name",
"experiments",
1,
"restart",
),
body=json.dumps(exp),
content_type="application/json",
status=200,
)
# Schema response
result = self.api_handler.restart("username", "project_name", 1)
assert result.to_dict() == exp
def test_stop_notebook(self):
httpretty.register_uri(
httpretty.POST,
BaseApiHandler.build_url(
self.api_config.base_url,
"/",
"username",
"project_name",
"notebook",
"stop",
),
content_type="application/json",
status=200,
)
result = self.api_handler.stop_notebook("username", "project_name")
assert result.status_code == 200
# Async
self.assert_async_call(
api_handler_call=lambda: self.api_handler.stop_notebook(
def test_enable_ci(self):
httpretty.register_uri(
httpretty.POST,
BaseApiHandler.build_url(
self.api_config.base_url, "/", "username", "project_name", "ci"
),
content_type="application/json",
status=201,
)
result = self.api_handler.enable_ci("username", "project_name")
assert result.status_code == 201
# Async
self.assert_async_call(
api_handler_call=lambda: self.api_handler.enable_ci(
"user", "project", background=True
),
method="post",
)
def test_update_project(self):
obj = ProjectConfig("proj").to_dict()
httpretty.register_uri(
httpretty.PATCH,
BaseApiHandler.build_url(self.api_config.base_url, "/", "user", "project"),
body=json.dumps(obj),
content_type="application/json",
status=200,
)
# Schema response
result = self.api_handler.update_project("user", "project", {"name": "new"})
assert result.to_dict() == obj
# Raw response
self.set_raw_response()
result = self.api_handler.update_project("user", "project", {"name": "new"})
assert result == obj
# Async
self.assert_async_call(
def test_activate_user(self):
httpretty.register_uri(
httpretty.POST,
BaseApiHandler.build_url(
self.api_config.base_url, "/users", "activate", "test-username"
),
content_type="application/json",
status=200,
)
response = self.api_handler.activate_user("test-username")
assert response.status_code == 200