bkyryliuk commented on a change in pull request #10429:
URL:
https://github.com/apache/incubator-superset/pull/10429#discussion_r461244487
##########
File path: tests/core_tests.py
##########
@@ -981,6 +981,43 @@ def test_import_csv(self):
os.remove(f1)
os.remove(f2)
+ def test_import_csv_filesize_limit(self):
+ max_bytes = app.config.get("UPLOAD_MAX_BYTES")
+ if not max_bytes:
+ return
+ self.login(username="admin")
+ table_name = "".join(random.choice(string.ascii_lowercase) for _ in
range(5))
+ f1 = "testSize.csv"
+ self.enable_csv_upload(utils.get_example_database())
+ repeat = max_bytes // 4
+ data = "a,b"
+ content = [data for _ in range(repeat)]
+ self.create_sample_csvfile(f1, content)
+ try:
+ success_msg_f1 = f'CSV file "{f1}" uploaded to table
"{table_name}"'
+
+ # initial upload with fail mode
+ resp = self.upload_csv(f1, table_name)
+ self.assertIn(success_msg_f1, resp)
+
+ # upload again with fail mode; should fail
+ fail_msg = f'Unable to upload CSV file "{f1}" to table
"{table_name}"'
+ fail_msg2 = (
Review comment:
I think I am missing smth here, could you please add a comment
explaining why 2nd upload exceeds the max bytes?
##########
File path: tests/core_tests.py
##########
@@ -981,6 +981,43 @@ def test_import_csv(self):
os.remove(f1)
os.remove(f2)
+ def test_import_csv_filesize_limit(self):
+ max_bytes = app.config.get("UPLOAD_MAX_BYTES")
+ if not max_bytes:
+ return
+ self.login(username="admin")
+ table_name = "".join(random.choice(string.ascii_lowercase) for _ in
range(5))
+ f1 = "testSize.csv"
+ self.enable_csv_upload(utils.get_example_database())
+ repeat = max_bytes // 4
+ data = "a,b"
+ content = [data for _ in range(repeat)]
+ self.create_sample_csvfile(f1, content)
+ try:
+ success_msg_f1 = f'CSV file "{f1}" uploaded to table
"{table_name}"'
+
+ # initial upload with fail mode
+ resp = self.upload_csv(f1, table_name)
+ self.assertIn(success_msg_f1, resp)
+
+ # upload again with fail mode; should fail
+ fail_msg = f'Unable to upload CSV file "{f1}" to table
"{table_name}"'
+ fail_msg2 = (
+ f"Error message: Exceeded the upload maximum size of
{max_bytes} bytes"
+ )
+ content.append(data)
+ self.create_sample_csvfile(f1, content)
+ resp = self.upload_csv(f1, table_name)
+ self.assertIn(fail_msg, resp)
+ self.assertIn(fail_msg2, resp)
+ # make sure that john and empty string are replaced with None
Review comment:
doesn't seem relevant
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]