def test_load_ini_staplesdata_off(self):
        config = configparser.ConfigParser()
        config.read(get_path('tool_test/ini', 'staples_data_off.ini', __name__))
        test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)
        x = test_config.get_logical_tests() + test_config.get_expression_tests()

        self.assertTrue(not x)
    def test_load_ini_bigquery_sql(self):
        config = configparser.ConfigParser()
        config.read(get_path('tool_test/ini', 'bigquery_sql.ini', __name__))
        test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)
        x = test_config.get_logical_tests() + test_config.get_expression_tests()

        test1 = LogicalTestSet(TEST_DIRECTORY, 'logical.calcs.bigquery_sql', 'cast_calcs.bigquery_sql.tds', '', 'logicaltests/setup/calcs/setup.*.bigquery_sql.xml', test_config.dsname)

        test2 = LogicalTestSet(TEST_DIRECTORY, 'logical.staples.bigquery_sql', 'Staples.bigquery_sql.tds', 'Filter.Trademark', 'logicaltests/setup/staples/setup.*.bigquery_sql.xml', test_config.dsname)

        test3 = LogicalTestSet(TEST_DIRECTORY, 'logical.lod.bigquery_sql', 'Staples.bigquery_sql.tds', '', 'logicaltests/setup/lod/setup.*.bigquery_sql.xml', test_config.dsname)

        test4 = ExpressionTestSet(TEST_DIRECTORY, 'expression.standard.bigquery_sql', 'cast_calcs.bigquery_sql.tds', 'string.ascii,string.char,string.bind_trim,string.left.real,string.right.real,dateparse,math.degree,math.radians,cast.str,cast.int.nulls,logical', 'exprtests/standard/setup.*.txt', test_config.dsname)

        test5 = ExpressionTestSet(TEST_DIRECTORY, 'expression_test_dates.bigquery_sql', 'cast_calcs.bigquery_sql_dates.tds', 'string.ascii,string.char,string.bind_trim,string.left.real,string.right.real,dateparse,math.degree,math.radians,cast.str,cast.int.nulls', 'exprtests/standard/', test_config.dsname)

        test6 = ExpressionTestSet(TEST_DIRECTORY, 'expression_test_dates2.bigquery_sql', 'cast_calcs.bigquery_sql_dates2.tds', 'string.ascii,string.char,string.bind_trim,string.left.real,string.right.real,dateparse,math.degree,math.radians,cast.str,cast.int.nulls', 'exprtests/standard/', test_config.dsname)

        test7 = ExpressionTestSet(TEST_DIRECTORY, 'expression.lod.bigquery_sql', 'cast_calcs.bigquery_sql.tds', '', 'exprtests/lodcalcs/setup.*.txt', test_config.dsname)

        test8 = LogicalTestSet(TEST_DIRECTORY, 'logical_test_dates.bigquery_sql', 'cast_calcs.bigquery_sql.tds', '', 'exprtests/standard/setup.*.bigquery_dates.xml', test_config.dsname)

        tests = [test1, test2, test3, test4, test5, test6, test7, test8]

        for test in tests:
            found = [y for y in x if y == test]
            self.assertTrue(found, "[Did not find expected value of [{0}]".format(test))
Esempio n. 3
0
    def test_load_command_line_override(self):
        config = configparser.ConfigParser()
        config.read(get_path('tool_test/ini', 'override.ini', __name__))
        test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)
        x = test_config.get_logical_tests() + test_config.get_expression_tests(
        )

        test1 = LogicalTestSet(
            TEST_DIRECTORY, 'logical.calcs.bigquery',
            'cast_calcs.bigquery.tds', '',
            'logicaltests/setup/calcs/setup.*.bigquery.xml')

        test2 = LogicalTestSet(
            TEST_DIRECTORY, 'logical.staples.bigquery', 'Staples.bigquery.tds',
            '', 'logicaltests/setup/staples/setup.*.bigquery.xml')

        test3 = ExpressionTestSet(TEST_DIRECTORY,
                                  'expression.standard.bigquery',
                                  'cast_calcs.bigquery.tds', '',
                                  'exprtests/standard/setup.*.txt')

        tests = [test1, test2, test3]

        self.assertTrue(
            test_config.d_override ==
            'WorkFaster=True Override=TurnOff:yes,TurnOn:no',
            'Override did not match: ' + test_config.d_override)

        for test in tests:
            found = [y for y in x if y == test]
            self.assertTrue(
                found, "[Did not find expected value of [{0}]".format(test))
Esempio n. 4
0
 def test_load_run_as_perf_false(self):
     config = configparser.ConfigParser()
     config.read(get_path('tool_test/ini', 'perf_false.ini', __name__))
     test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)
     self.assertFalse(
         test_config.run_as_perf,
         'run_as_perf did not match: ' + str(test_config.run_as_perf))
Esempio n. 5
0
    def test_load_ini_new_tests(self):
        config = configparser.ConfigParser()
        config.read(get_path('tool_test/ini', 'new_tests.ini', __name__))
        test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)
        x = test_config.get_logical_tests() + test_config.get_expression_tests(
        )

        for a in x:
            print(a)

        test1 = LogicalTestSet(TEST_DIRECTORY,
                               'logical_test1.bigquery_sql_test',
                               'Staples.bigquery.tds', '',
                               'logicaltests/setup.*.bigquery.xml')
        test2 = LogicalTestSet(TEST_DIRECTORY,
                               'logical_test2.bigquery_sql_test',
                               'Staples.bigquery_sql_test.tds', '',
                               'logicaltests/setup.*.bigquery.xml')

        test3 = ExpressionTestSet(TEST_DIRECTORY,
                                  'expression_test1.bigquery_sql_test',
                                  'cast_calcs.bigquery_sql_dates2.tds',
                                  'string.ascii', 'exprtests/standard/')
        test4 = ExpressionTestSet(TEST_DIRECTORY,
                                  'expression_test2.bigquery_sql_test',
                                  'cast_calcs.bigquery_sql_test.tds',
                                  'string.char', 'exprtests/standard/')

        tests = [test1, test2, test3, test4]

        for test in tests:
            found = [y for y in x if y == test]
            self.assertTrue(
                found, "[Did not find expected value of [{0}]".format(test))
Esempio n. 6
0
    def test_load_ini_bigquery(self):
        config = configparser.ConfigParser()
        config.read(get_path('tool_test/ini', 'bigquery.ini', __name__))
        test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)
        x = test_config.get_logical_tests() + test_config.get_expression_tests(
        )

        test1 = LogicalTestSet(
            TEST_DIRECTORY, 'logical.calcs.bigquery',
            'cast_calcs.bigquery.tds', '',
            'logicaltests/setup/calcs/setup.*.bigquery.xml')

        test2 = LogicalTestSet(
            TEST_DIRECTORY, 'logical.staples.bigquery', 'Staples.bigquery.tds',
            '', 'logicaltests/setup/staples/setup.*.bigquery.xml')

        test3 = ExpressionTestSet(
            TEST_DIRECTORY, 'expression.standard.bigquery',
            'cast_calcs.bigquery.tds',
            'string.ascii,string.char,string.bind_trim,string.left.real,string.right.real,dateparse',
            'exprtests/standard/setup.*.txt')

        tests = [test1, test2, test3]

        for test in tests:
            found = [y for y in x if y == test]
            self.assertTrue(
                found, "[Did not find expected value of [{0}]".format(test))
Esempio n. 7
0
    def test_load_ini_missing2(self):
        config = configparser.ConfigParser()
        config.read(get_path('tool_test/ini', 'aurora_missing2.ini', __name__))
        test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)
        x = test_config.get_logical_tests() + test_config.get_expression_tests(
        )

        test1 = LogicalTestSet(TEST_DIRECTORY, 'logical.calcs.aurora',
                               'cast_calcs.aurora.tds', '',
                               'logicaltests/setup/calcs/setup.*.bool_.xml')

        test2 = LogicalTestSet(TEST_DIRECTORY, 'logical.staples.aurora',
                               'Staples.aurora.tds', '',
                               'logicaltests/setup/staples/setup.*.bool_.xml')

        test3 = ExpressionTestSet(TEST_DIRECTORY, 'expression.standard.aurora',
                                  'cast_calcs.aurora.tds', '',
                                  'exprtests/standard/setup.*.txt')

        tests = [test1, test2, test3]

        for test in tests:
            found = [y for y in x if y == test]
            self.assertTrue(
                found, "[Did not find expected value of [{0}]".format(test))
Esempio n. 8
0
    def test_load_ini(self):
        config = configparser.ConfigParser()
        config.read(get_path('tool_test/ini', 'aurora.ini', __name__))
        test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)
        x = test_config.get_logical_tests() + test_config.get_expression_tests(
        )

        test1 = LogicalTestSet(TEST_DIRECTORY, 'logical.calcs.aurora',
                               'cast_calcs.aurora.tds', '',
                               'logicaltests/setup/calcs/setup.*.bool_.xml')

        test2 = LogicalTestSet(TEST_DIRECTORY, 'logical.staples.aurora',
                               'Staples.aurora.tds', 'Filter.Trademark',
                               'logicaltests/setup/staples/setup.*.bool_.xml')

        test3 = LogicalTestSet(TEST_DIRECTORY, 'logical.lod.aurora',
                               'Staples.aurora.tds', '',
                               'logicaltests/setup/lod/setup.*.bool_.xml')

        test4 = ExpressionTestSet(TEST_DIRECTORY, 'expression.standard.aurora',
                                  'cast_calcs.aurora.tds',
                                  'string.char,dateparse',
                                  'exprtests/standard/setup.*.txt')

        test5 = ExpressionTestSet(TEST_DIRECTORY, 'expression.lod.aurora',
                                  'cast_calcs.aurora.tds', '',
                                  'exprtests/lodcalcs/setup.*.txt')

        tests = [test1, test2, test3, test4, test5]

        for test in tests:
            found = [y for y in x if y == test]
            msg = "[Did not find expected value of [{0}]".format(test)
            self.assertTrue(found, msg)
Esempio n. 9
0
 def test_logical_rerun_fail(self):
     tests = enqueue_failed_tests(
         get_path('tool_test/rerun_failed_tests',
                  'logical_compare_sql.json', __name__), TEST_DIRECTORY,
         None)
     all_test_results = tdvt_core.run_tests_serial(tests)
     self.check_results(all_test_results, 1, False)
    def test_load_ini_password_file(self):
        config = configparser.ConfigParser()
        config.read(get_path('tool_test/ini', 'password_file.ini', __name__))
        test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)
        x = test_config.get_logical_tests() + test_config.get_expression_tests()

        expected_password_file = "a_wrong.password"
        self.assertTrue(len(x) == 10, "[Did not find expected number of tests. Found [{0}]".format(len(x)))
        for test in x:
            actual_file = os.path.split(test.get_password_file_name())[1]
            self.assertTrue(actual_file == expected_password_file, "[Did not find expected value of [{0}, found {1} instead.]".format(expected_password_file, actual_file))
    def test_load_ini_staplesdata_on(self):
        config = configparser.ConfigParser()
        config.read(get_path('tool_test/ini', 'staples_data.ini', __name__))
        test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)
        x = test_config.get_logical_tests() + test_config.get_expression_tests()

        test1 = ExpressionTestSet(TEST_DIRECTORY, 'expression.staples.bigquery', 'Staples.bigquery.tds', '', 'exprtests/staples/setup.*.txt', test_config.dsname)

        tests = [test1]
        for test in tests:
            found = [y for y in x if y == test]
            self.assertTrue(found, "[Did not find expected value of [{0}]".format(test))
    def test_load_ini_logical_config(self):
        config = configparser.ConfigParser()
        #Preserve the case of elements.
        config.optionxform = str
        config.read(get_path('tool_test/ini', 'logical_config.ini', __name__))
        test_config = datasource_list.LoadTest(config, TEST_DIRECTORY)

        cfg = test_config.logical_config['my_logical_query']
        self.assertTrue(test_config.logical_config_name == 'my_logical_query')
        self.assertTrue(cfg['tablename'] == 'CRAZYTABLE_$dsName')
        self.assertTrue(cfg['tablePrefix'] == '[LOCO].')
        self.assertTrue(cfg['tablenameUpper'] == 'True')
    def test_load_windows_override(self):
        ini_file = get_path('tool_test/ini', 'windows_override.ini', __name__)
        reg = datasource_list.TestRegistry('')
        reg.load_registry(ini_file)

        #Duplicates should be removed and the order preserved.
        standard = ['teradata', 'netezza']
        all_passing = ['teradata', 'netezza', 'bigquery', 'exasolution']
        all_test = ['hadoophive2_hortonworks', 'teradata', 'netezza', 'bigquery', 'exasolution']
        all_test2 = ['hadoophive2_hortonworks', 'teradata', 'netezza', 'bigquery', 'exasolution']

        self.assertTrue(standard == reg.get_datasources('standard'))
        self.assertTrue(all_passing == reg.get_datasources('all_passing'))
        self.assertTrue(all_test == reg.get_datasources('all_test'))
        self.assertTrue(all_test2 == reg.get_datasources('all_test2'))
    def test_failed_test_output(self):
        """Make sure TDVT writes the correct output file for rerunning failed tests."""
        all_test_results = {}
        #This will cause the test to fail as expected.
        self.test_config.tested_sql = True
        all_test_results = tdvt_core.run_tests_impl(self.config_set, self.test_config)
        tdvt_core.write_standard_test_output(all_test_results, self.test_dir)

        self.check_results(all_test_results, 1, False)

        #Now rerun the failed tests which should fail again, indicating that the 'tested_sql' option was persisted correctly.

        tests = enqueue_failed_tests(get_path('tool_test', 'tdvt_output.json', __name__), TEST_DIRECTORY, None)
        all_test_results = tdvt_core.run_tests_serial(tests)

        self.check_results(all_test_results, 1, False)
 def test_combined_rerun_local_tests(self):
     tests = enqueue_failed_tests(get_path('tool_test/rerun_failed_tests', 'combined_local.json', __name__), TEST_DIRECTORY, None)
     all_test_results = tdvt_core.run_tests_serial(tests)
     self.check_results(all_test_results, 5)
 def test_expression_rerun(self):
     tests = enqueue_failed_tests(get_path('tool_test/rerun_failed_tests','exprtests.json', __name__), TEST_DIRECTORY, None)
     all_test_results = tdvt_core.run_tests_serial(tests)
     self.check_results(all_test_results, 2)