def do_save_to_csv(self, params): ''' Saves specified file to csv. [command_line] input_file output_file Author: Peter ''' # print(params, type(params)) input_file = [] if params == '': params = 'plants.py output.csv' args = params.split(' ') # print(args) if len(args) >= 1: input_file.append(args[0]) output_file = 'output.csv' if len(args) >= 2: output_file = args[1] if input_file[0].endswith('.py'): fileprocessor = model.FileProcessor() fileprocessor.process_files(input_file) modules = fileprocessor.get_modules() # print(modules) csv_writer = csv.CSV_handler() if csv_writer.write_csv_file(modules, output_file): print('File successfully saved as {}'.format(output_file))
def test_class_name(self): """ Checks plants.py class names have been appended correctly Author: Braeden """ file_processor = model.FileProcessor() file_processor.process_files(self.individual_file_upload) self.assertTrue(file_processor.modules['plants'][0].name is 'Orchid')
def test_13_pickle_module(self): data_for_model = ['plants.py'] newModelData = model.FileProcessor() newModelData.process_files(data_for_model) model_data_module = newModelData.get_modules() pickler = PickleModules() expected = len(model_data_module) actual = len(pickler.load()) self.assertEqual(expected, actual)
def test_multiple_file_processed(self): """ Is multiple modules created after processing of file? Author: Braeden """ file_processor = model.FileProcessor() modules = file_processor.process_files(["plants.py", "controller.py"]) self.assertTrue(modules == 2)
def test_12_pickle_module(self): data_for_model = ['plants.py'] newModelData = model.FileProcessor() newModelData.process_files(data_for_model) model_data_module = newModelData.get_modules() pickler = PickleModules() expected = True actual = pickler.save(model_data_module) self.assertEqual(expected, actual)
def test_individual_file_processed(self): """ Is individual module created after processing of file? Author: Braeden """ file_processor = model.FileProcessor() modules = file_processor.process_files(self.individual_file_upload) self.assertTrue(modules == 1)
def test_protected_function_symbol_checker(self): """ Checks if the provided method name is private, public or protected Author: Braeden """ md = model.FileProcessor() visibility = md.get_visibility_of_string("_public_function") self.assertTrue(visibility == "#")
def test_03_compare_output(self): # Compares plugin output with output generated by model data_for_model = ['linkedlist.py'] newModelData = model.FileProcessor() newModelData.process_files(data_for_model) model_data_module = newModelData.get_modules() testclass = CSV_handler() expected = testclass.write_csv_file(model_data_module, 'testdatafile02.csv') test_module = testclass.open_file('test_data_file01.csv')
def run_parser(self, hide_attributes, hide_methods): if len(self.controller.files) > 0: processor = model.FileProcessor(self.controller.statistics) processor.process_files(self.controller.files) self.controller.extracted_modules = processor.get_modules() new_uml = uml_out.MakeUML(hide_attributes, hide_methods) return new_uml.create_class_diagram(self.controller.extracted_modules) else: print("Error: No files were set, use command change_python_files")
def test_14_pickle_module(self): data_for_model = ['plants.py'] newModelData = model.FileProcessor() newModelData.process_files(data_for_model) pickler = PickleModules() actual = True try: expected = TypeError test = pickler.save() except TypeError: actual = TypeError self.assertEqual(expected, actual)
def test_process_multiple_files(self): """ Long Method - Test 2 Can the model still process multiple files? Author: Michael Huang """ expected = 2 statistics = StatisticsCreator("MyRefactor") statistics.create_tables() file_processor = model.FileProcessor(statistics) processor = file_processor.process_files(self.multiple_files) output = processor self.assertEqual(expected, output)
def do_pickle_modules(self, filename='plants.py'): ''' Load modules from single file and save them using pickle Author: Peter Command: pickle_modules filename eg pickle_modules plants.py ''' file = [filename] parser = model.FileProcessor() parser.process_files(file) modules = parser.get_modules() pickler = PickleModules() return pickler.save(modules)
def test_model_process_multi_class(self): """ Location: 'model.py-FileProcessor-process_class-Lines(126-170)' Testing whether the file processor will still process a class correctly and return the correct number of modules using multiple files Author: Jake """ expected = 2 statistics = StatisticsCreator("RefactorTestDB") statistics.create_tables() file_processor = model.FileProcessor(statistics) modules = file_processor.process_files(self.multi_file_test) actual = modules self.assertEqual(expected, actual)
def test_run_parser_multi(self): """ Location: 'model.py-FileProcessor-process_class-Lines(126-170)' Testing whether the processed module can be used to create a uml diagram with multiple files Author: Jake """ statistics = StatisticsCreator("RefactorTestDB") statistics.create_tables() processor = model.FileProcessor(statistics) processor.process_files(self.multi_file_test) extracted_modules = processor.get_modules() new_uml = uml_out.MakeUML(False, False) expected = new_uml.create_class_diagram(extracted_modules) controller = Controller() controller.files = self.multi_file_test actual = controller.run_parser(False, False) self.assertEqual(expected, actual)