Skip to content

Commit

Permalink
SK-1736: Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saileshwar-skyflow committed Dec 4, 2024
1 parent a741e6e commit 1297d5a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 0 additions & 3 deletions skyflow/utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ def construct_invoke_connection_request(request, connection_url, logger) -> Prep
if not hasattr(request.method, 'value'):
raise SkyflowError(SkyflowMessages.Error.INVALID_REQUEST_METHOD.value, invalid_input_error_code)

if not request.method.value:
raise SkyflowError(SkyflowMessages.Error.INVALID_REQUEST_METHOD.value, invalid_input_error_code)

try:
return requests.Request(
method = request.method.value,
Expand Down
4 changes: 1 addition & 3 deletions skyflow/vault/controller/_connections.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import json
import requests

from skyflow.error import SkyflowError
from skyflow.generated.rest.exceptions import UnauthorizedException
from skyflow.utils import construct_invoke_connection_request, SkyflowMessages, get_metrics, \
parse_invoke_connection_response, handle_exception
parse_invoke_connection_response
from skyflow.utils.logger import log_info
from skyflow.vault.connection import InvokeConnectionRequest

Expand Down
15 changes: 15 additions & 0 deletions tests/utils/test__utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ def test_construct_invoke_connection_request_with_invalid_headers(self):

self.assertEqual(context.exception.message, SkyflowMessages.Error.INVALID_REQUEST_HEADERS.value)

def test_construct_invoke_connection_request_with_invalid_request_method(self):
mock_connection_request = Mock()
mock_connection_request.path_params = {"param1": "value1"}
mock_connection_request.headers = {"Content-Type": ContentType.JSON.value}
mock_connection_request.body = {"key": "value"}
mock_connection_request.method = "POST"
mock_connection_request.query_params = {"query": "test"}

connection_url = "https://example.com/{param1}/endpoint"

with self.assertRaises(SkyflowError) as context:
result = construct_invoke_connection_request(mock_connection_request, connection_url, logger=None)

self.assertEqual(context.exception.message, SkyflowMessages.Error.INVALID_REQUEST_METHOD.value)

def test_construct_invoke_connection_request_with_invalid_request_body(self):
mock_connection_request = Mock()
mock_connection_request.path_params = {"param1": "value1"}
Expand Down

0 comments on commit 1297d5a

Please sign in to comment.