def test_config_ok(self): errors = check_config(self.input_file, translate_separator(self.separator), self.columns_to_show, self.help_column, self.output_file, self.class_column, self.classes) self.assertTrue(len(errors) == 0)
def test_control_file_saved(self): output_file = 'data/output_test.csv' self.df.to_csv('data/output_test_partial.csv', sep=';', encoding='utf-8') errors = check_config(self.input_file, translate_separator(self.separator), self.columns_to_show, self.default_column, output_file, self.class_column, self.classes) self.assertTrue('Looks like there is a control file saved and' ' class column specified is not an existing column in it.' in errors)
def test_output_path_no_exists(self): output_file = 'data/output_test.csv' errors = check_config(self.input_file, translate_separator(self.separator), self.columns_to_show, self.help_column, output_file, self.class_column, self.classes) self.assertTrue('Output path does not exist' in errors)
def test_no_output_file(self): output_file = '' errors = check_config(self.input_file, translate_separator(self.separator), self.columns_to_show, self.help_column, output_file, self.class_column, self.classes) self.assertTrue('You must to specify an output file' in errors)
def test_no_columns_to_show(self): columns_to_show = [] errors = check_config(self.input_file, translate_separator(self.separator), columns_to_show, self.help_column, self.output_file, self.class_column, self.classes) self.assertTrue('Columns to show not specified.' in errors)
def test_no_classes(self): help_column = '' classes = [] errors = check_config(self.input_file, translate_separator(self.separator), self.columns_to_show, help_column, self.output_file, self.class_column, classes) self.assertTrue('There are not defined classes.' in errors)
def test_class_column_in_columns(self): class_column = 'col2' errors = check_config(self.input_file, translate_separator(self.separator), self.columns_to_show, self.help_column, self.output_file, class_column, self.classes) self.assertTrue( 'Column col2 already exists in the CSV file.' in errors)
def test_no_help_column(self): help_column = 'col3' errors = check_config(self.input_file, translate_separator(self.separator), self.columns_to_show, help_column, self.output_file, self.class_column, self.classes) self.assertTrue( 'Help column does not exist in the CSV file.' in errors)
def test_output_file_exists(self): output_file = 'output_test.csv' self.df.to_csv('output_test.csv', sep=';', encoding='utf-8') errors = check_config(self.input_file, translate_separator(self.separator), self.columns_to_show, self.help_column, output_file, self.class_column, self.classes) self.assertTrue( 'Looks like exists a finished output file. Drop it if you want to start again.' in errors)
def test_column_to_show_no_exist(self): columns_to_show = [ 'col3', ] errors = check_config(self.input_file, translate_separator(self.separator), columns_to_show, self.help_column, self.output_file, self.class_column, self.classes) self.assertTrue( 'col3 column does not exist in the CSV file.' in errors)
def test_no_class_column(self): class_column = '' errors = check_config(self.input_file, translate_separator(self.separator), self.columns_to_show, self.default_column, self.output_file, class_column, self.classes) self.assertTrue('You must to specify a class column' in errors)
def test_translate_separator(self): self.assertEqual(translate_separator('semicolon'), ';') self.assertEqual(translate_separator('coma'), ',')
def test_input_output_not_same(self): output_file = 'data/output_test.csv' errors = check_config(self.input_file, translate_separator(self.separator), self.columns_to_show, self.default_column, output_file, self.class_column, self.classes) self.assertFalse('Input and output must be different files' in errors)