示例#1
0
 def test_valid_mergespec_file_output_format(self):
     self._log.info(
         'test_valid_mergespec_file_output_format() - testing...')
     valid_ds_input_file = os.path.join(self._run_context.tests_safe_dir,
                                        DS_INPUT_FILE_VALID)
     input_tables = {FLAT_TABLE_KEY_NAME: VALID_DS_INPUT_TABLE_NAME}
     dbutilities.drop_table_if_exists(
         db_context=self._run_context.getDBContext(),
         table=VALID_DS_INPUT_TABLE_NAME)
     input_table_reader = SafeExcelReader(
         run_context=self._run_context,
         filename=valid_ds_input_file,
         sheet_name=DS_INPUT_FILE_SHEET_VALID,
         db_context=self._run_context.getDBContext(),
         output_table=VALID_DS_INPUT_TABLE_NAME)
     input_table_reader.createTable()
     mergespec_file = 'C:/{}'.format(MERGESPEC_OUTPUT_FILE)
     if os.path.exists(mergespec_file):
         os.remove(mergespec_file)
     cmpmrg = ComplementaryMerge(run_context=self._run_context)
     cmpmrg.create_mergespec_file(input_table_names=input_tables,
                                  new_mergespec_file=mergespec_file)
     self._log.info('test_valid_mergespec_file_output_format() - tested.')
     filename1 = mergespec_file
     filename2 = os.path.join(self._run_context.tests_safe_dir,
                              COMPARE_FILE_MERGESPEC_OUTPUT)
     assert filecmp.cmp(
         filename1,
         filename2), 'Python test output does not match expected output.'
示例#2
0
 def test_cmf_null_mergespec_file(self):
     self._log.info('test_null_mergespec_file() - testing...')
     cmpmrg = ComplementaryMerge(run_context=self._run_context)
     with self.assertRaises(StandardError):
         cmpmrg.create_mergespec_file(input_table_name='no_table',
                                      new_mergespec_file=None)
     self._log.info('test_null_mergespec_file() - tested.')
示例#3
0
 def test_mergespec_file_already_exists(self):
     self._log.info('test_mergespec_file_already_exists() - testing...')
     mergespec_file = os.path.join(self._run_context.tests_safe_dir,
                                   MERGESPEC_FILE_VALID)
     cmpmrg = ComplementaryMerge(run_context=self._run_context)
     with self.assertRaises(IOError):
         cmpmrg.create_mergespec_file(
             input_table_names={FLAT_TABLE_KEY_NAME: 'no_table'},
             new_mergespec_file=mergespec_file)
     self._log.info('test_mergespec_file_already_exists() - tested.')
示例#4
0
def create_mergespec_file(run_context, input_table_names, new_mergespec_file):
    cmpmrg = ComplementaryMerge(run_context=run_context)
    cmpmrg.create_mergespec_file(input_table_names=input_table_names,
                                 new_mergespec_file=new_mergespec_file)