summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHarel Ben-Attia <harelba@gmail.com>2017-04-06 18:58:20 +0300
committerHarel Ben-Attia <harelba@gmail.com>2017-04-06 18:58:20 +0300
commit94bae328b5e083a2e1fbe87b9d40062efd97971a (patch)
treed543b254177909dfe9b9550f0c5f16aa28b24188 /test
parent24ab831958743618a71d837981cf62722e97fcee (diff)
Added control over max field size + info when failing on this1.6.1v1.6.0-release-test
Diffstat (limited to 'test')
-rwxr-xr-xtest/test-suite109
1 files changed, 96 insertions, 13 deletions
diff --git a/test/test-suite b/test/test-suite
index 717e9c8..a0f6fcc 100755
--- a/test/test-suite
+++ b/test/test-suite
@@ -801,7 +801,7 @@ class BasicTests(AbstractQTestCase):
def test_non_quoted_values_in_quoted_data(self):
tmp_data_file = self.create_file_with_data(sample_quoted_data)
-
+
cmd = '../bin/q -d " " "select c1 from %s"' % tmp_data_file.name
retcode, o, e = run_command(cmd)
@@ -819,7 +819,7 @@ class BasicTests(AbstractQTestCase):
def test_regular_quoted_values_in_quoted_data(self):
tmp_data_file = self.create_file_with_data(sample_quoted_data)
-
+
cmd = '../bin/q -d " " "select c2 from %s"' % tmp_data_file.name
retcode, o, e = run_command(cmd)
@@ -836,7 +836,7 @@ class BasicTests(AbstractQTestCase):
def test_double_double_quoted_values_in_quoted_data(self):
tmp_data_file = self.create_file_with_data(sample_quoted_data)
-
+
cmd = '../bin/q -d " " "select c3 from %s"' % tmp_data_file.name
retcode, o, e = run_command(cmd)
@@ -853,7 +853,7 @@ class BasicTests(AbstractQTestCase):
def test_escaped_double_quoted_values_in_quoted_data(self):
tmp_data_file = self.create_file_with_data(sample_quoted_data)
-
+
cmd = '../bin/q -d " " "select c4 from %s"' % tmp_data_file.name
retcode, o, e = run_command(cmd)
@@ -880,7 +880,7 @@ class BasicTests(AbstractQTestCase):
self.assertEquals(o[0],'"quoted,data",23')
self.assertEquals(o[1],'unquoted-data,54,')
-
+
self.cleanup(tmp_data_file)
def test_none_input_quoting_mode_in_strict_mode(self):
@@ -1061,7 +1061,7 @@ class BasicTests(AbstractQTestCase):
self.cleanup(tmp_data_file)
def test_input_field_quoting_and_data_types_with_encoding(self):
- # Checks combination of minimal input field quoting, with special characters that need to be decoded -
+ # Checks combination of minimal input field quoting, with special characters that need to be decoded -
# Both content and proper data types are verified
data = '111,22.22,"testing text with special characters - citt\xc3\xa0 ",http://somekindofurl.com,12.13.14.15,12.1\n'
tmp_data_file = self.create_file_with_data(data,encoding='none')
@@ -1094,7 +1094,7 @@ class BasicTests(AbstractQTestCase):
def test_multiline_double_double_quoted_values_in_quoted_data(self):
tmp_data_file = self.create_file_with_data(sample_quoted_data)
-
+
# FIXME Need to convert \0a to proper encoding suitable for the person running the tests.
cmd = '../bin/q -d " " "select replace(c5,X\'0A\',\'::\') from %s"' % tmp_data_file.name
retcode, o, e = run_command(cmd)
@@ -1112,7 +1112,7 @@ class BasicTests(AbstractQTestCase):
def test_multiline_escaped_double_quoted_values_in_quoted_data(self):
tmp_data_file = self.create_file_with_data(sample_quoted_data)
-
+
# FIXME Need to convert \0a to proper encoding suitable for the person running the tests.
cmd = '../bin/q -d " " "select replace(c6,X\'0A\',\'::\') from %s"' % tmp_data_file.name
retcode, o, e = run_command(cmd)
@@ -1129,11 +1129,11 @@ class BasicTests(AbstractQTestCase):
self.cleanup(tmp_data_file)
def test_disable_double_double_quoted_data_flag__values(self):
- # This test (and flag) is meant to verify backward comptibility only. It is possible that
+ # This test (and flag) is meant to verify backward comptibility only. It is possible that
# this flag will be removed completely in the future
tmp_data_file = self.create_file_with_data(double_double_quoted_data)
-
+
cmd = '../bin/q -d " " --disable-double-double-quoting "select c2 from %s" -W none' % tmp_data_file.name
retcode, o, e = run_command(cmd)
@@ -1167,11 +1167,11 @@ class BasicTests(AbstractQTestCase):
self.cleanup(tmp_data_file)
def test_disable_escaped_double_quoted_data_flag__values(self):
- # This test (and flag) is meant to verify backward comptibility only. It is possible that
+ # This test (and flag) is meant to verify backward comptibility only. It is possible that
# this flag will be removed completely in the future
tmp_data_file = self.create_file_with_data(escaped_double_quoted_data)
-
+
cmd = '../bin/q -d " " --disable-escaped-double-quoting "select c2 from %s" -W none' % tmp_data_file.name
retcode, o, e = run_command(cmd)
@@ -1205,7 +1205,7 @@ class BasicTests(AbstractQTestCase):
self.cleanup(tmp_data_file)
def test_combined_quoted_data_flags__number_of_columns_detected(self):
- # This test (and flags) is meant to verify backward comptibility only. It is possible that
+ # This test (and flags) is meant to verify backward comptibility only. It is possible that
# these flags will be removed completely in the future
tmp_data_file = self.create_file_with_data(combined_quoted_data)
@@ -1258,6 +1258,86 @@ class BasicTests(AbstractQTestCase):
self.assertEquals(e[0],"No files matching 'non-existent-file' have been found")
+ def test_default_column_max_length_parameter__short_enough(self):
+ huge_text = "x" * 131000
+
+ file_data = "a,b,c\n1,%s,3\n" % huge_text
+
+ tmpfile = self.create_file_with_data(file_data)
+
+ cmd = '../bin/q -H -d , "select a from %s"' % tmpfile.name
+ retcode, o, e = run_command(cmd)
+
+ self.assertEquals(retcode, 0)
+ self.assertEquals(len(o), 1)
+ self.assertEquals(len(e), 0)
+
+ self.assertEquals(o[0],'1')
+
+ self.cleanup(tmpfile)
+
+ def test_default_column_max_length_parameter__too_long(self):
+ huge_text = "x" * 132000
+
+ file_data = "a,b,c\n1,%s,3\n" % huge_text
+
+ tmpfile = self.create_file_with_data(file_data)
+
+ cmd = '../bin/q -H -d , "select a from %s"' % tmpfile.name
+ retcode, o, e = run_command(cmd)
+
+ self.assertEquals(retcode, 31)
+ self.assertEquals(len(o), 0)
+ self.assertEquals(len(e), 1)
+
+ self.assertTrue(e[0].startswith("Column length is larger than the maximum"))
+ self.assertTrue(("Offending file is '%s'" % tmpfile.name) in e[0])
+ self.assertTrue('Line is 2' in e[0])
+
+ self.cleanup(tmpfile)
+
+ def test_column_max_length_parameter(self):
+ file_data = "a,b,c\nvery-long-text,2,3\n"
+ tmpfile = self.create_file_with_data(file_data)
+
+ cmd = '../bin/q -H -d , -M 3 "select a from %s"' % tmpfile.name
+ retcode, o, e = run_command(cmd)
+
+ self.assertEquals(retcode, 31)
+ self.assertEquals(len(o), 0)
+ self.assertEquals(len(e), 1)
+
+ self.assertTrue(e[0].startswith("Column length is larger than the maximum"))
+ self.assertTrue(("Offending file is '%s'" % tmpfile.name) in e[0])
+ self.assertTrue('Line is 2' in e[0])
+
+ cmd2 = '../bin/q -H -d , -M 300 -H "select a from %s"' % tmpfile.name
+ retcode2, o2, e2 = run_command(cmd2)
+
+ self.assertEquals(retcode2, 0)
+ self.assertEquals(len(o2), 1)
+ self.assertEquals(len(e2), 0)
+
+ self.assertEquals(o2[0],'very-long-text')
+
+ self.cleanup(tmpfile)
+
+ def test_invalid_column_max_length_parameter(self):
+ file_data = "a,b,c\nvery-long-text,2,3\n"
+ tmpfile = self.create_file_with_data(file_data)
+
+ cmd = '../bin/q -H -d , -M 0 "select a from %s"' % tmpfile.name
+ retcode, o, e = run_command(cmd)
+
+ self.assertEquals(retcode, 31)
+ self.assertEquals(len(o), 0)
+ self.assertEquals(len(e), 1)
+
+ self.assertTrue(e[0].startswith('Max column length limit must be a positive integer'))
+
+
+ self.cleanup(tmpfile)
+
class ParsingModeTests(AbstractQTestCase):
def test_strict_mode_column_count_mismatch_error(self):
@@ -1580,6 +1660,7 @@ class ParsingModeTests(AbstractQTestCase):
self.cleanup(tmpfile)
+
class FormattingTests(AbstractQTestCase):
def test_column_formatting(self):
@@ -1607,6 +1688,7 @@ class FormattingTests(AbstractQTestCase):
self.assertEquals(o[1], '55.000 5.500')
+
class SqlTests(AbstractQTestCase):
def test_find_example(self):
@@ -1761,6 +1843,7 @@ class SqlTests(AbstractQTestCase):
self.cleanup(tmpfile)
+
class BasicModuleTests(AbstractQTestCase):
def test_simple_query(self):