def test_list_entries(self): for test_idx, (input_str, output_ref_str) in \ enumerate(fix_test_list_def(test_list_link)): obj_d = hpp2plantuml.Diagram() # Not very unittest-y obj_d.create_from_string(input_str) if len(obj_d._inheritance_list) > 0: obj_l = obj_d._inheritance_list[0] elif len(obj_d._aggregation_list) > 0: obj_l = obj_d._aggregation_list[0] nt.assert_equal( output_ref_str, obj_l.render(), 'Test {0} failed [input: {1}]'.format(test_idx, input_str))
def _test_full_files_helper(self, flag_dep=False): # Create first version file_list_ref = list( set( hpp2plantuml.hpp2plantuml.expand_file_list( [os.path.join(test_fold, f) for f in self._input_files]))) diag_ref = hpp2plantuml.Diagram(flag_dep=flag_dep) diag_ref.create_from_file_list(file_list_ref) diag_render_ref = diag_ref.render() # Compare to saved reference if flag_dep: saved_ref = self._diag_saved_ref else: saved_ref = self._diag_saved_ref_nodep nt.assert_equal(saved_ref, diag_render_ref) # # Validate equivalent inputs # File expansion for file_list in [self._input_files, self._input_files_w]: file_list_c = list( set( hpp2plantuml.hpp2plantuml.expand_file_list( [os.path.join(test_fold, f) for f in file_list]))) # Create from file list diag_c = hpp2plantuml.Diagram(flag_dep=flag_dep) diag_c.create_from_file_list(file_list_c) nt.assert_equal(diag_render_ref, diag_c.render()) # Add from file list diag_c_add = hpp2plantuml.Diagram(flag_dep=flag_dep) diag_c_add.add_from_file_list(file_list_c) diag_c_add.build_relationship_lists() diag_c_add.sort_elements() nt.assert_equal(diag_render_ref, diag_c_add.render()) # Create from first file, add from rest of the list diag_c_file = hpp2plantuml.Diagram(flag_dep=flag_dep) diag_c_file.create_from_file(file_list_c[0]) for file_c in file_list_c[1:]: diag_c_file.add_from_file(file_c) diag_c_file.build_relationship_lists() diag_c_file.sort_elements() nt.assert_equal(diag_render_ref, diag_c_file.render()) # String inputs input_str_list = [] for file_c in file_list_ref: with open(file_c, 'rt') as fid: input_str_list.append(fid.read()) # Create from string list diag_str_list = hpp2plantuml.Diagram(flag_dep=flag_dep) diag_str_list.create_from_string_list(input_str_list) nt.assert_equal(diag_render_ref, diag_str_list.render()) # Add from string list diag_str_list_add = hpp2plantuml.Diagram(flag_dep=flag_dep) diag_str_list_add.add_from_string_list(input_str_list) diag_str_list_add.build_relationship_lists() diag_str_list_add.sort_elements() nt.assert_equal(diag_render_ref, diag_str_list_add.render()) # Create from string diag_str = hpp2plantuml.Diagram(flag_dep=flag_dep) diag_str.create_from_string('\n'.join(input_str_list)) nt.assert_equal(diag_render_ref, diag_str.render()) # Reset and parse diag_str.clear() diag_str.create_from_string('\n'.join(input_str_list)) nt.assert_equal(diag_render_ref, diag_str.render()) # Manually build object diag_manual_add = hpp2plantuml.Diagram(flag_dep=flag_dep) for idx, (file_c, string_c) in enumerate(zip(file_list_ref, input_str_list)): if idx == 0: diag_manual_add.add_from_file(file_c) else: diag_manual_add.add_from_string(string_c) diag_manual_add.build_relationship_lists() diag_manual_add.sort_elements() nt.assert_equal(diag_render_ref, diag_manual_add.render())