Exemple #1
0
    def test_compare_data_frames(self):
        """Test a function to compare data frames."""

        df1 = load_expected_case(1)[0]
        df2 = load_expected_case(1)[0]
        df3 = load_expected_case(2)[0]

        self.assertTrue(compare_data_frames(df1, df2))

        with self.assertRaises(AssertionError):
            compare_data_frames(df1, df3)
Exemple #2
0
    def run_case_with_parameters(self,
                                 case_num,
                                 specific_params=None,
                                 special_case=None):
        """Run a test case with parameters using ParameterDiscovery strategy.

        Args:
            case_num (int): The test case number to run.
        """
        test_wb = load_original_case(case_num)
        params = load_parameters_case(case_num)
        params["data_ends"] = None
        exp_dfs = load_expected_case(case_num, special_case)

        if specific_params:
            for specific_param, value in specific_params.items():
                params[specific_param] = value

        # get dfs from the strategy
        series = XlSeries(test_wb)
        test_dfs = series.get_data_frames(params)

        if type(test_dfs) != list:
            test_dfs = [test_dfs]
        if type(exp_dfs) != list:
            exp_dfs = [exp_dfs]

        for test_df, exp_df in zip(test_dfs, exp_dfs):
            print(test_df.columns, exp_df.columns)
            self.assertTrue(compare_data_frames(test_df, exp_df))
Exemple #3
0
    def run_case_without_some_parameters(self,
                                         case_num,
                                         specific_params=None,
                                         special_case=None):
        """Run a test case deleting some parameters.

        Args:
            case_num: The test case number to run.
        """
        test_wb = get_orig_cases_path(case_num)
        params = load_parameters_case(case_num)
        exp_dfs = load_expected_case(case_num, special_case)

        params.remove_non_critical()
        if specific_params:
            for specific_param, value in specific_params.items():
                params[specific_param] = value

        # change safe_mode to True, for complete test in safe_mode (very slow)
        safe_mode = False
        series = XlSeries(test_wb)
        test_dfs = series.get_data_frames(params, safe_mode=safe_mode)

        # get them always into a list
        if type(test_dfs) != list:
            test_dfs = [test_dfs]
        if type(exp_dfs) != list:
            exp_dfs = [exp_dfs]

        for test_df, exp_df in zip(test_dfs, exp_dfs):
            self.assertTrue(compare_data_frames(test_df, exp_df))