def test_compare_xl(self): Utility.remove_file_if_exists(self.diff_file) cxl = CompareXl(self.existing_left, self.existing_right, self.sheet1, self.sheet1) diffs = cxl.compare() cxl.save_differences(self.diff_file, diffs) self.assertTrue(os.path.exists(self.diff_file))
def test_compare_index_save(self): Utility.remove_file_if_exists(self.diff_file) compare = CompareXl(self.existing_left, self.right_file, self.sheet1, self.sheet1) diffs = compare.compare_index(6) compare.save_differences(self.diff_file, diffs) self.assertTrue(os.path.exists(self.diff_file))
def run(self, file1, file2, diff_file, sheet_name, sql1, sql2=None): """Run SQL on two databases, save to Excel files, compare those files and save differences""" sql2 = sql1 if sql2 is None else sql2 sql_run1 = SqlToXl(self.conn1) sql_run1.save_sql(sql1, file1, sheet_name) sql_run2 = SqlToXl(self.conn2) sql_run2.save_sql(sql2, file2, sheet_name) compare_xl = CompareXl(file1, file2, sheet_name, sheet_name) compare_xl.compare_and_save(diff_file)
def test_run_and_compare(self): sql_str = "exec dbo.spExportAggregatorClosedEnd '10/27/17'" sql_run_qa = SqlToXl(self.left_db) sql_run_qa.save_sql(sql_str, self.qa_file, self.default_sheet) sql_run_prod = SqlToXl(self.right_db) sql_run_prod.save_sql(sql_str, self.prod_file, self.default_sheet) compare = CompareXl(self.qa_file, self.prod_file, self.default_sheet, self.default_sheet) compare.save_differences(self.db_diff_file, compare.compare()) self.assertTrue(os.path.exists(self.db_diff_file))
def compare_only(file1, file2, diff_file, sheet_name, index=None): """Static Method. No SQL is run, just compare two files and save differences. Index optional.""" compare = CompareXl(file1, file2, sheet_name, sheet_name) if index is None: diffs = compare.compare() else: diffs = compare.compare_index(index) compare.save_differences(diff_file, diffs)
def test_compare_index(self): compare = CompareXl(self.existing_left, self.existing_right, self.sheet1, self.sheet1) diffs = compare.compare_index(6) self.assertTrue(len(diffs) > 1)