|
3 | 3 | #
|
4 | 4 | # Copyright (c) 2012-2017 Snowflake Computing Inc. All right reserved.
|
5 | 5 | #
|
| 6 | +import os |
6 | 7 | from getpass import getuser
|
7 | 8 | from logging import getLogger
|
8 | 9 |
|
9 |
| -import os |
10 | 10 | import pytest
|
11 | 11 |
|
12 | 12 | logger = getLogger(__name__)
|
@@ -186,7 +186,8 @@ def test_put_local_file(test_data, conn_cnx):
|
186 | 186 | cur.execute("rm @%pytest_putget_t1")
|
187 | 187 | results = cur.fetchall()
|
188 | 188 | 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'") |
190 | 191 | results = cur.fetchall()
|
191 | 192 | assert results[0][0] == 'LOADED', (
|
192 | 193 | 'history does not show file to be loaded')
|
@@ -406,3 +407,40 @@ def test_unload(test_data, conn_cnx):
|
406 | 407 | "drop stage {stage_name}".format(
|
407 | 408 | stage_name=test_data.stage_name))
|
408 | 409 | 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