Skip to content

Commit 20459d1

Browse files
committed
SNOW-27634: adding PUT with auto_compress=FALSE test case
1 parent 2534853 commit 20459d1

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

test/test_put_get.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#
44
# Copyright (c) 2012-2017 Snowflake Computing Inc. All right reserved.
55
#
6+
import os
67
from getpass import getuser
78
from logging import getLogger
89

9-
import os
1010
import pytest
1111

1212
logger = getLogger(__name__)
@@ -186,7 +186,8 @@ def test_put_local_file(test_data, conn_cnx):
186186
cur.execute("rm @%pytest_putget_t1")
187187
results = cur.fetchall()
188188
assert len(results) == 2, 'two files were not removed'
189-
cur.execute("select STATUS from information_schema.load_history where table_name='PYTEST_PUTGET_T1'")
189+
cur.execute(
190+
"select STATUS from information_schema.load_history where table_name='PYTEST_PUTGET_T1'")
190191
results = cur.fetchall()
191192
assert results[0][0] == 'LOADED', (
192193
'history does not show file to be loaded')
@@ -406,3 +407,40 @@ def test_unload(test_data, conn_cnx):
406407
"drop stage {stage_name}".format(
407408
stage_name=test_data.stage_name))
408409
cur.close()
410+
411+
412+
def test_put_with_auto_compress_false(tmpdir, db_parameters):
413+
"""
414+
Test PUT command with auto_compress=False
415+
"""
416+
import snowflake.connector
417+
cnx = snowflake.connector.connect(
418+
user=db_parameters['s3_user'],
419+
password=db_parameters['s3_password'],
420+
host=db_parameters['s3_host'],
421+
port=db_parameters['s3_port'],
422+
database=db_parameters['s3_database'],
423+
account=db_parameters['s3_account'],
424+
protocol=db_parameters['s3_protocol'])
425+
426+
tmp_dir = str(tmpdir.mkdir('data'))
427+
test_data = os.path.join(tmp_dir, 'data.txt')
428+
with open(test_data, 'w') as f:
429+
f.write("test1,test2")
430+
f.write("test3,test4")
431+
432+
cnx.cursor().execute("RM @~/test_put_uncompress_file")
433+
try:
434+
with cnx.cursor() as cur:
435+
for rec in cur.execute("""
436+
PUT file://{0} @~/test_put_uncompress_file auto_compress=FALSE
437+
""".format(test_data)):
438+
print(rec)
439+
440+
ret = cnx.cursor().execute("""
441+
LS @~/test_put_uncompress_file
442+
""").fetchone()
443+
assert "test_put_uncompress_file/data.txt" in ret[0]
444+
assert "data.txt.gz" not in ret[0]
445+
finally:
446+
cnx.cursor().execute("RM @~/test_put_uncompress_file")

0 commit comments

Comments
 (0)