def test_listsorter_ValidOutput(self): ls = ListSorter() in_filename = "ValidFile.csv" out_filename = "OutputFile.csv" self.create_csvfile_random_content(in_filename, 50) self.assertEqual(StatusCode.SUCCESS, ls.set_input_data(in_filename)) self.assertEqual(StatusCode.SUCCESS, ls.set_output_data(out_filename)) self.delete_file(in_filename) self.delete_file(out_filename)
def test_listsorter_QuickSort(self): ls = ListSorter() in_filename = "QuickSortData.csv" out_filename = "SortedByQuickSort.csv" self.create_csvfile_random_content(in_filename, 50000) self.assertEqual(StatusCode.SUCCESS, ls.set_input_data(in_filename)) self.assertEqual(StatusCode.SUCCESS, ls.execute_quick_sort()) self.assertEqual(StatusCode.SUCCESS, ls.set_output_data(out_filename)) self.delete_file(in_filename) self.delete_file(out_filename)
def test_listsorter_QuickSortVSHeapSort(self): QuickSort = ListSorter() HeapSort = ListSorter() in_filename = "InputData.csv" self.create_csvfile_random_content(in_filename, 5000) # Read Input File to respective Sort self.assertEqual(StatusCode.SUCCESS, QuickSort.set_input_data(in_filename)) self.assertEqual(StatusCode.SUCCESS, HeapSort.set_input_data(in_filename)) #Execute Sorts QuickSort.execute_merge_sort() HeapSort.execute_quick_sort() #Compare Lists self.assertListEqual(QuickSort.working_list, HeapSort.working_list) self.delete_file(in_filename)
def test_listsorter_HeapSortAlreadySorted(self): ls = ListSorter() in_filename = "HeapSortData.csv" out_filename = "SortedByHeapSort.csv" self.create_csvfile_random_content(in_filename, 10) self.assertEqual(StatusCode.SUCCESS, ls.set_input_data(in_filename)) self.assertEqual(StatusCode.SUCCESS, ls.execute_heap_sort()) self.assertEqual(StatusCode.SUCCESS, ls.set_output_data(out_filename)) self.assertEqual(StatusCode.LIST_ALREADY_SORTED, ls.execute_heap_sort()) self.delete_file(in_filename) self.delete_file(out_filename)
def test_listsorter_InvalidFilename(self): ls = ListSorter() filename = 55 self.assertEqual(StatusCode.PARAM_ERROR, ls.set_input_data(filename))
def test_listsorter_NotAFile(self): ls = ListSorter() filename = "IDoNotExist.txt" self.assertEqual(StatusCode.NOT_A_FILE, ls.set_input_data(filename))
def test_listsorter_NotACVSFile(self): ls = ListSorter() filename = "NotACSVFile.txt" self.create_csvfile_random_content(filename, 10) self.assertEqual(StatusCode.INVALID_FILE_EXTENSION, ls.set_input_data(filename)) self.delete_file(filename)
def test_listsorter_InvalidCSVFile(self): ls = ListSorter() filename = "InvalidFile.csv" self.create_file_with_content(filename, "123 456 765\n567 876 987 hi") self.assertEqual(StatusCode.FILE_ERROR, ls.set_input_data(filename)) self.delete_file(filename)
def test_listsorter_PerformanceData(self): ls = ListSorter() ls.get_performance_data()
def test_listsorter_QuickSortEmptyList(self): ls = ListSorter() self.assertEqual(StatusCode.LIST_IS_EMPTY, ls.execute_quick_sort())
def test_listsorter_InvalidParam(self): ls = ListSorter() out_filename = 55 self.assertEqual(StatusCode.PARAM_ERROR, ls.set_output_data(out_filename))
def test_listsorter_ValidCSVFile(self): ls = ListSorter() filename = "ValidFile.csv" self.create_csvfile_random_content(filename, 50000) self.assertEqual(StatusCode.SUCCESS, ls.set_input_data(filename)) self.delete_file(filename)