Skip to content

Commit 68b0d3f

Browse files
committed
updated test and using enums
Signed-off-by: Sreekanth Vadigi <[email protected]>
1 parent dd375bb commit 68b0d3f

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/databricks/sql/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
)
6868
from databricks.sql.telemetry.latency_logger import log_latency
6969
from databricks.sql.telemetry.models.enums import StatementType
70-
from databricks.sql.common.http import DatabricksHttpClient, HttpMethod
70+
from databricks.sql.common.http import DatabricksHttpClient, HttpMethod, UploadType
7171

7272
logger = logging.getLogger(__name__)
7373

@@ -773,7 +773,7 @@ def _handle_staging_put_stream(
773773
headers=headers,
774774
timeout=300, # 5 minute timeout
775775
) as response:
776-
self._validate_staging_http_response(response, "stream upload")
776+
self._validate_staging_http_response(response, UploadType.STREAM_UPLOAD.value)
777777

778778
@log_latency(StatementType.SQL)
779779
def _handle_staging_put(
@@ -793,7 +793,7 @@ def _handle_staging_put(
793793
with open(local_file, "rb") as fh:
794794
r = requests.put(url=presigned_url, data=fh, headers=headers)
795795

796-
self._validate_staging_http_response(r, "file upload")
796+
self._validate_staging_http_response(r, UploadType.FILE_UPLOAD.value)
797797

798798
@log_latency(StatementType.SQL)
799799
def _handle_staging_get(

src/databricks/sql/common/http.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class HttpHeader(str, Enum):
2525
AUTHORIZATION = "Authorization"
2626

2727

28+
class UploadType(str, Enum):
29+
FILE_UPLOAD = "file_upload"
30+
STREAM_UPLOAD = "stream_upload"
31+
32+
2833
# Dataclass for OAuthHTTP Response
2934
@dataclass
3035
class OAuthResponse:

tests/e2e/common/streaming_put_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ def test_streaming_put_basic(self, catalog, schema):
1919

2020
# Create test data
2121
test_data = b"Hello, streaming world! This is test data."
22-
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
23-
filename = f"stream_test_{timestamp}.txt"
22+
filename = "streaming_put_test.txt"
2423
file_path = f"/Volumes/{catalog}/{schema}/e2etests/{filename}"
2524

2625
try:
2726
with self.connection() as conn:
2827
with conn.cursor() as cursor:
28+
self._cleanup_test_file(file_path)
29+
2930
with io.BytesIO(test_data) as stream:
3031
cursor.execute(
3132
f"PUT '__input_stream__' INTO '{file_path}'",

0 commit comments

Comments
 (0)