def test_list_fields(self): model = UMLModel() model.create_class("class1") # variables used for testing equality message = model.list_fields("class3")[1] # test output equality with a non-existent class self.assertEqual(message, "class3 is not a class") # variables used for testing equality message = model.list_fields("class1")[1] # test output equality without inserting fields self.assertEqual(message, "Class 'class1' has no fields") # add some fields to class1 model.create_field("class1", "public", "int", "year") model.create_field("class1", "private", "int", "salary") model.create_field("class1", "protected", "string", "SSN") # variables used for testing equality message = model.list_fields("class1")[1] outString = "".join(("Fields of class1\n", "PUBLIC int year\n", "PRIVATE int salary\n", "PROTECTED string SSN")) # test output equality self.assertEqual(message,outString)
def test_delete_class(self): model = UMLModel() model.create_class("class1") model.create_class("class2") # create relationship between classes model.create_relationship("composition", "class1", "class2") # Ensure relationship is created self.assertTrue(model.classes["class1"].has_relationship("class2")) self.assertTrue(model.classes["class2"].has_relationship("class1")) # Ensure deleted model.delete_class("class1") # assert dictionary key was removed self.assertTrue("class1" not in model.classes) # Ensure relationship was removed after deletion of class1 status, msg = model.list_relationships("class2") self.assertTrue(status) self.assertEqual(msg, "Class 'class2' has no relationships") # Ensure no errors when class DNE status, msg = model.delete_class("class1") # ensure it failed self.assertFalse(status) self.assertEqual(msg, "class1 does not exist.")
def test_execute(self): # create model model_name = "myModel" model = UMLModel() model.create_class("class1") model.create_class("class2") model.create_relationship("composition", "class1", "class2") model.save_model(model_name + ".json", directory=os.getcwd() + "/") class_data = { "filename": model_name + ".json", "directory": os.getcwd() + "/", "class_name1": "class1", "class_name2": "class2" } cmd = DeleteRelationshipGUICommand(model, class_data) cmd.saveBackup() status, msg = cmd.execute() # ensure it passed self.assertTrue(status) # ensure relationship was deleted self.assertTrue(len(model.classes["class1"].relationships) == 0) self.assertTrue(len(model.classes["class2"].relationships) == 0) # ensure it fails when invalid cmd = DeleteRelationshipGUICommand(model, class_data) cmd.saveBackup() status, msg = cmd.execute() self.assertFalse(status)
def test_rename_parameter(self): model = UMLModel() model.create_class("class1") model.create_method("class1", "public", "string", "method1") model.create_parameter("class1", "method1", "param_type", "param_name") # Ensure we get correct output when class doesn't exist status, msg = model.rename_parameter("class9", "method1", "param_name", "new_param_name") self.assertFalse(status) self.assertEqual(msg, "class9 does not exist") # Ensure we get correct output when method doesn't exist status, msg = model.rename_parameter("class1", "method3", "param_name", "new_param_name") self.assertFalse(status) self.assertEqual(msg, "class1 does not have method, method3") # Ensure we get correct output when the parameter we wish to rename doesn't exist status, msg = model.rename_parameter("class1", "method1", "param_name7", "new_param_name") self.assertFalse(status) self.assertEqual(msg, " param_name7 does not exists in method1") # Ensure we get correct output when the parameter we wish to rename already exists status, msg = model.rename_parameter("class1", "method1", "param_name", "param_name") self.assertFalse(status) self.assertEqual(msg, " param_name already exists in method1") #ensure parameter is renamed model.rename_parameter("class1", "method1", "param_name", "new_param_name") # Ensure duplicate parameter is not created self.assertEqual(model.classes["class1"].methods[model.classes["class1"].method_index("method1")].parameters[0].name, "new_param_name")
def test_move_down_method(self): model = UMLModel() model.create_class("class1") model.create_method("class1", "public", "string", "method1") model.create_method("class1", "public", "string", "method2") model.create_method("class1", "public", "string", "method3") testClass = model.classes["class1"] # Ensure the methods'position self.assertEqual(testClass.methods[0].name, "method1") self.assertEqual(testClass.methods[1].name, "method2") self.assertEqual(testClass.methods[2].name, "method3") # Move down the method one position from the list model.move_down_method("class1", "method2") # Ensure the method has a right position after moved self.assertEqual(testClass.method_index("method1"), 0) self.assertEqual(testClass.method_index("method3"), 1) self.assertEqual(testClass.method_index("method2"), 2) # Ensure the method don't move down further status, msg = model.move_down_method("class1", "method2") self.assertFalse(status) # Ensure correct response is outputted when class doesn't exist status, msg = model.move_down_method("class7", "method2") self.assertFalse(status) self.assertEqual(msg, "class7 does not exist") # Ensure correct response is outputted when method doesn't exist status, msg = model.move_down_method("class1", "method9") self.assertFalse(status) self.assertEqual(msg, "method9 does not exist in class1")
def test_list_parameters(self): model = UMLModel() model.create_class("class1") # variables used for testing equality message = model.list_parameters("class2", "test")[1] # test output equality with using a non-existent class self.assertEqual(message, "class2 does not exist") # variables used for testing equality message = model.list_parameters("class1", "test")[1] # test output equality without inserting methods self.assertEqual(message, "class1 does not have method, test") # add some methods to class1 model.create_method("class1", "public", "int", "getYear") # add some params to getYear model.create_parameter("class1", "getYear", "string", "calendarName") model.create_parameter("class1", "getYear", "int", "year") # variables used for testing equality message = model.list_parameters("class1", "getYear")[1] outString = "".join(("Parameters for getYear\n", "(string):calendarName\n", "(int):year")) # test output equality self.assertEqual(message,outString)
def test_delete_parameter(self): model = UMLModel() model.create_class("class1") model.create_method("class1", "public", "string", "method1") model.create_parameter("class1", "method1", "param_type", "parameter_name") testClass = model.classes["class1"] # Ensure we get correct output when class doesn't exist status, msg = model.delete_parameter("class9", "method1", "parameter_name") self.assertFalse(status) self.assertEqual(msg, "class9 does not exist") # Ensure we get correct output when method doesn't exist status, msg = model.delete_parameter("class1", "method6", "parameter_name") self.assertFalse(status) self.assertEqual(msg, "class1 does not have method, method6") # Ensure parameter is deleted status, msg = model.delete_parameter("class1", "method1", "parameter_name") self.assertFalse(testClass.methods[testClass.method_index("method1")].has_parameter("parameter_name")) # Ensure we get correct output after parameter is deleted self.assertTrue(status) self.assertEqual(msg, "parameter 'parameter_name' has been removed from 'method1'") # Ensure we get correct output if the parameter we wish to delete doesn't exist status, msg = model.delete_parameter("class1", "method1", "parameter_name") self.assertFalse(status) self.assertEqual(msg, " parameter_name does not exists in method1")
def test_create_relationship(self): model = UMLModel() model.create_class("c1") model.create_class("c2") # Ensure relationship is created model.create_relationship("composition", "c1", "c2") self.assertTrue(model.classes["c1"].has_relationship("c2")) self.assertTrue(model.classes["c2"].has_relationship("c1")) status, msg = model.create_relationship("invalidRealType", "c5", "c2") self.assertFalse(status) self.assertEqual(msg, "'invalidRealType' is not a valid relationship type.") # Ensure we get correct output when class 1 doesn't exist status, msg = model.create_relationship("realization", "c5", "c2") self.assertFalse(status) self.assertEqual(msg, "'c5' does not exist") # Ensure we get correct output when class 2 doesn't exist status, msg = model.create_relationship("realization", "c1", "c5") self.assertFalse(status) self.assertEqual(msg, "'c5' does not exist") # Ensure already existing rel status, msg = model.create_relationship("composition","c2","c1") # ensure it failed self.assertFalse(status) self.assertEqual(msg, "Relationship between 'c2' and 'c1' already exists.")
def test_delete_relationship(self): model = UMLModel() model.create_class("c1") model.create_class("c2") model.create_relationship("realization", "c1", "c2") # Ensure we get correct output when class 1 doesn't exist status, msg = model.delete_relationship("c7","c2") self.assertFalse(status) self.assertEqual(msg, "c7 does not exist") # Ensure we get correct output when class 2 doesn't exist status, msg = model.delete_relationship("c1","c5") self.assertFalse(status) self.assertEqual(msg, "c5 does not exist") # Ensure relationship is deleted status, msg = model.delete_relationship("c1","c2") self.assertEqual(len(model.classes["c1"].relationships), 0) self.assertEqual(len(model.classes["c2"].relationships), 0) # Ensure we get correct output after relationship has been deleted self.assertTrue(status) self.assertEqual(msg, "Relationship between c1 and c2 has been deleted") # Ensure we get correct output if we try to delete relationship that doesn't exist status, msg = model.delete_relationship("c1","c2") self.assertFalse(status) self.assertEqual(msg, "Relationship between c1 and c2 does not exist.")
def test_complete_rename_class(self): model = UMLModel() model.create_class("class1") model.create_class("myclass") repl = REPL(model, CommandHistory(HISTORY_LIMIT)) # Test 1: Tab before classname classnames = repl.complete_rename_class("", "rename_class ", 0, 0) self.assertEqual(classnames, ["class1", "myclass"]) # Test 2: Tab in the middle of classname - only one match classnames = repl.complete_rename_class("cl", "rename_class cl", 0, 0) self.assertEqual(classnames, ["class1"]) # Test 3: Tab after classname classnames = repl.complete_rename_class("class1", "rename_class class1", 0, 0) self.assertEqual(classnames, ["class1"]) # Test 4: Tab before second classname classnames = repl.complete_rename_class("", "rename_class class1 ", 0, 0) self.assertEqual(classnames, []) # Test 5: Tab after second classname classnames = repl.complete_rename_class( "newclassname", "rename_class class1 newclassname", 0, 0) self.assertEqual(classnames, [])
def test_rename_class(self): model = UMLModel() model.create_class("class1") # Ensure name is changed model.rename_class("class1", "classA") # assert dictionary key was changed self.assertTrue("classA" in model.classes) #assert class object name was changed self.assertEqual(model.classes["classA"].name, "classA") # Ensure unknown class is rejected status, msg = model.rename_class("class1", "classB") self.assertFalse(status) self.assertEqual(msg, "class1 does not exist.") # Ensure duplicate newname is rejected model.create_class("class1") status, msg = model.rename_class("classA", "class1") # ensure it failed self.assertFalse(status) self.assertEqual(msg, "class1 already exists.") # Ensure renamed class with relationship updates # relationship in both classes self.assertTrue(model.create_class("class2")[0]) self.assertTrue(model.create_relationship("inheritance", "class1", "class2")[0]) self.assertTrue(model.rename_class("class2", "class3")[0]) self.assertEqual(model.classes["class1"].relationships[0].other, "class3")
def test_list_methods(self): model = UMLModel() model.create_class("class1") # variables used for testing equality message = model.list_methods("class3")[1] # test output equality with a non-existent class self.assertEqual(message, "class3 does not exist") # variables used for testing equality message = model.list_methods("class1")[1] # test output equality without inserting methods self.assertEqual(message, "class1 has no methods") # add some methods to class1 model.create_method("class1", "public", "int", "getYear") model.create_method("class1", "private", "int", "getSalary") model.create_method("class1", "protected", "string", "getSSN") # variables used for testing equality message = model.list_methods("class1")[1] outString = "".join(("Methods for class1\n", "PUBLIC getYear() : int\n", "PRIVATE getSalary() : int\n", "PROTECTED getSSN() : string")) # test output equality self.assertEqual(message,outString)
def test_do_create_field(self): model = UMLModel() model.create_class("class1") command_history = CommandHistory(HISTORY_LIMIT) repl = REPL(model, command_history) repl.do_create_field("class1 private int age") # ensure field was created self.assertTrue(model.classes["class1"].field_index("age") != -1)
def test_create_class(self): model = UMLModel() # Ensure class is created model.create_class("class1") self.assertEqual(model.classes["class1"].name, "class1") # Ensure duplicate class is not created status, msg = model.create_class("class1") self.assertFalse(status) self.assertEqual(msg, "class1 already exists.")
def test_complete_rename_parameter(self): model = UMLModel() model.create_class("class1") model.create_method("class1", "public", "int", "method1") model.create_parameter("class1", "method1", "int", "a") model.create_parameter("class1", "method1", "int", "b") model.create_parameter("class1", "method1", "int", "abba") model.create_method("class1", "public", "int", "method2") model.create_method("class1", "public", "int", "mymethod") model.create_class("myclass") repl = REPL(model, CommandHistory(HISTORY_LIMIT)) # Test 1: Tab before classname classnames = repl.complete_rename_parameter("", "rename_parameter ", 0, 0) self.assertEqual(classnames, ["class1", "myclass"]) # Test 2: Tab in the middle of classname - only one match classnames = repl.complete_rename_parameter("cl", "rename_parameter cl", 0, 0) self.assertEqual(classnames, ["class1"]) # Test 3: Tab before methodname classnames = repl.complete_rename_parameter( "", "rename_parameter class1 ", 0, 0) self.assertEqual(classnames, ["method1", "method2", "mymethod"]) # Test 4: Tab during methodname classnames = repl.complete_rename_parameter( "met", "rename_parameter class1 met", 0, 0) self.assertEqual(classnames, ["method1", "method2"]) # Test 5: Tab before old param name classnames = repl.complete_rename_parameter( "", "rename_parameter class1 method1 ", 0, 0) self.assertEqual(classnames, ["a", "b", "abba"]) # Test 6: Tab during old param name classnames = repl.complete_rename_parameter( "a", "rename_parameter class1 method1 a", 0, 0) self.assertEqual(classnames, ["a", "abba"]) # Test 7: Tab after old param name classnames = repl.complete_rename_parameter( "", "rename_parameter class1 method1 abba ", 0, 0) self.assertEqual(classnames, []) # Test 8: Tab after old param name classnames = repl.complete_rename_parameter( "iLikePie", "rename_parameter class1 method1 abba iLikePie", 0, 0) self.assertEqual(classnames, [])
def test_set_class_position(self): model = UMLModel() model.create_class("class1") # variables used for testing equality message = model.set_class_position("class3", 10, 20, 30)[1] # test output equality when class3 is a non-existent class self.assertEqual(message, "class3 does not exist") # set position of c1 message = model.set_class_position("class1", 10, 20, 0)[1] # test output equality self.assertEqual(message, "The position of 'class1' has been set to ('10', '20')")
def test_find_field(self): model = UMLModel() model.create_class("class1") testClass = model.classes["class1"] # create some fields model.create_field("class1", "public", "void", "a1") model.create_field("class1", "private", "int", "num") # ensure fields are found in the right indices self.assertEqual(model.find_field("class1", "a1"), 0) self.assertEqual(model.find_field("class1", "num"), 1) # ensure we get correct output when field is not found self.assertEqual(model.find_field("class1", "nonexistent"), -1)
def test_fetch_from_method(self): model = UMLModel() model.create_class("class1") model.create_method("class1", "public", "int", "method1") model.create_parameter("class1", "method1", "int", "num") model.create_parameter("class1", "method1", "bool", "isTrue") model.create_method("class1", "public", "bool", "method2") # Test 1: get parameters params = fetch_from_method(model, "class1", "method1") self.assertEqual(params, ["num", "isTrue"]) # Test 2: no parameters params = fetch_from_method(model, "class1", "method2") self.assertEqual(params, [])
def test_fetch_classes(self): model = UMLModel() # Test 1: no classes classes = fetch_classes(model) self.assertEqual(classes, []) # Test 2: multiple classes model.create_class("class1") model.create_class("class2") model.create_class("class3") classes = fetch_classes(model) self.assertTrue("class1" in classes) self.assertTrue("class2" in classes) self.assertTrue("class3" in classes)
def test_move_down_field(self): model = UMLModel() model.create_class("class1") model.create_field("class1", "public", "void", "a1") model.create_field("class1", "public", "void", "a2") model.create_field("class1", "public", "void", "a3") model.create_field("class1", "public", "void", "a4") # ensure the class is created testClass = model.classes["class1"] # Ensure the fields were created self.assertTrue(testClass.has_field("a1")) self.assertTrue(testClass.has_field("a2")) self.assertTrue(testClass.has_field("a3")) self.assertTrue(testClass.has_field("a4")) # Ensure the fields'position self.assertEqual(testClass.fields[0].name, "a1") self.assertEqual(testClass.fields[1].name, "a2") self.assertEqual(testClass.fields[2].name, "a3") self.assertEqual(testClass.fields[3].name, "a4") # Move down the field one position from the list model.move_down_field("class1", "a1") # Ensure the field has a right position self.assertEqual(testClass.field_index("a2"), 0) self.assertEqual(testClass.field_index("a1"), 1) self.assertEqual(testClass.field_index("a3"), 2) self.assertEqual(testClass.field_index("a4"), 3) # Ensure the method don't move down further status, msg = model.move_down_field("class1", "a4") self.assertFalse(status) self.assertEqual(msg, "a4 can not move down any further in class1") # Ensure correct response is outputted when class doesn't exist status, msg = model.move_down_field("class8", "a4") self.assertFalse(status) self.assertEqual(msg, "class8 does not exist") # Ensure correct response is outputted when field doesn't exist status, msg = model.move_down_field("class1", "a7") self.assertFalse(status) self.assertEqual(msg, "a7 does not exist in class1")
def test_create_field(self): model = UMLModel() model.create_class("class1") testClass = model.classes["class1"] # Ensure field is created model.create_field("class1", "public", "void", "a1") self.assertTrue(testClass.has_field("a1")) # Ensure we get correct output when class does not exist status, msg = model.create_field("class5", "private", "void", "a1") self.assertFalse(status) self.assertEqual(msg, "class5 does not exist") # Ensure duplicate field is not created status, msg = model.create_field("class1", "public", "void", "a1") # ensure it failed self.assertFalse(status) self.assertEqual(msg, "field a1 already exists in class1")
def test_delete_field(self): model = UMLModel() model.create_class("class1") model.create_field("class1", "public", "void", "a1") testClass = model.classes["class1"] # Ensure we get correct output when class doesn't exist status, msg = model.delete_field("class5", "a1") self.assertFalse(status) self.assertEqual(msg, "class5 does not exist") # Ensure we get correct output when field we wish to remove doesn't exist status, msg = model.delete_field("class1", "a3") self.assertFalse(status) self.assertEqual(msg, "a3 is not a field of class1") # Ensure field is deleted model.delete_field("class1", "a1") self.assertFalse(testClass.has_field("a1"))
def test_delete_method(self): model = UMLModel() model.create_class("class1") model.create_method("class1", "public", "void", "add") testClass = model.classes["class1"] # Ensure we get correct output when class doesn't exist status, msg = model.delete_method("class4", "add") self.assertFalse(status) self.assertEqual(msg, "'class4' does not exist") # Ensure we get correct output when the method we wish to delete doesn't exist status, msg = model.delete_method("class1", "subtract") self.assertFalse(status) self.assertEqual(msg, "'subtract' does not exist in 'class1'") # Ensure method is deleted model.delete_method("class1", "add") self.assertFalse(testClass.has_method("add"))
def test_prompt_exit(self): # Test 1: fully exit exits = False try: # give 'no' response for prompt_exit to grab and exit sys.stdin = io.StringIO("no\n") prompt_exit(UMLModel()) except SystemExit: exits = True # make sure it exited self.assertTrue(exits) # Test 2: cancel exit exits = False try: # give 'cancel' response for prompt_exit sys.stdin = io.StringIO("cancel\n") status, msg = prompt_exit(UMLModel()) except SystemExit: exits = True # make sure it didnt exit self.assertFalse(exits) self.assertEqual(msg, "Exit aborted") # Test 3: save model model1 = UMLModel() model1.create_class("class1") model1.create_class("class2") exits = False captured = io.StringIO() try: # give 'yes' response for prompt_exit to grab and exit sys.stdin = io.StringIO("yes\ntest_prompt_exit.json\n") prompt_exit(model1, os.getcwd() + "/code/data/") except SystemExit: exits = True # make sure it exited self.assertTrue(exits) # make sure it saved model2 = UMLModel() model2.load_model("test_prompt_exit.json", os.getcwd() + "/code/data/") self.assertEqual(model1.classes.keys(), model2.classes.keys())
def test_create_method(self): model = UMLModel() model.create_class("class1") testClass = model.classes["class1"] # Ensure method is created model.create_method("class1", "public", "void", "add") self.assertTrue(testClass.has_method("add")) # Ensure we get correct output when class doesn't exist status, msg = model.create_method("class3", "public", "void", "subtract") self.assertFalse(status) self.assertEqual(msg, "class3 does not exist") # Ensure duplicate method is not created status, msg = model.create_method("class1", "public", "void", "add") # ensure it failed self.assertFalse(status) self.assertEqual(msg, "method add already exists in class1")
def test_execute(self): # create model model_name = "myModel" model = UMLModel() model.create_class("class1") model.create_class("class2") model.create_relationship("composition", "class1", "class2") model.save_model(model_name + ".json", directory=os.getcwd() + "/") class_data = { "filename": model_name + ".json", "directory": os.getcwd() + "/", "old_relationship_type": "composition", "old_class_name1": "class1", "old_class_name2": "class2", "relationship_type": "inheritance", "class_name1": "class1", "class_name2": "class2" } cmd = EditRelationshipGUICommand(model, class_data) cmd.saveBackup() status, msg = cmd.execute() # ensure it passed self.assertTrue(status) # relationship exists self.assertTrue(len(model.classes["class1"].relationships) == 1) self.assertTrue(len(model.classes["class2"].relationships) == 1) self.assertEqual(model.classes["class1"].relationships[0].type, RelationshipType.INHERITANCE) self.assertEqual(model.classes["class1"].relationships[0].other, "class2") self.assertEqual(model.classes["class2"].relationships[0].other, "class1") # ensure it fails when invalid class_data["class_name2"] = "invalid_class" cmd = EditRelationshipGUICommand(model, class_data) cmd.saveBackup() status, msg = cmd.execute() self.assertFalse(status)
def test_fetch_from_class(self): model = UMLModel() model.create_class("class1") model.create_class("class2") model.create_field("class1", "public", "string", "field1") model.create_field("class1", "public", "int", "field2") model.create_method("class1", "public", "int", "method1") model.create_method("class1", "public", "bool", "method2") model.create_relationship("inheritance", "class1", "class2") # Test 1: fetch fields fields = fetch_from_class(model, "class1", "fields") self.assertEqual(fields, ["field1", "field2"]) # Test 2: fetch methods methods = fetch_from_class(model, "class1", "methods") self.assertEqual(methods, ["method1", "method2"]) # Test 3: empty list fields = fetch_from_class(model, "class2", "fields") self.assertEqual(fields, [])
def test_list_classes(self): model = UMLModel() # variables used for testing equality message = model.list_classes()[1] # test output equality without creating classes self.assertEqual(message, "No classes in the model") # create some classes model.create_class("class1") model.create_class("class2") model.create_class("class3") # variables used for testing equality message = model.list_classes()[1] outString = "".join(("Listing all classes in the model\n", "class1\n", "class2\n", "class3")) # test output equality self.assertEqual(message,outString)
def test_list_relationships(self): model = UMLModel() model.create_class("class1") model.create_class("class2") # variables used for testing equality message = model.list_relationships("class5")[1] # test output equality with using a non-existent class name self.assertEqual(message, "class5 does not exist") # test with a parameter # variables used for testing equality message = model.list_relationships('class1')[1] # test output equality without creating a relationship self.assertEqual(message, "Class 'class1' has no relationships") # test without a parameter # variables used for testing equality message = model.list_relationships()[1] # test output equality without creating a relationship self.assertEqual(message, "No relationships exist for the current model") # create a relationship between the classes model.create_relationship("inheritance", "class1", "class2") # test with a parameter message = model.list_relationships("class1")[1] # test output equality outString = "".join(("Relationships for class1\n", "class1 ---------> class2")) self.assertEqual(message, outString) # test without a parameter # variables used for testing equality message = model.list_relationships()[1] outString = "".join(("Listing all relationships\n", "class1 ---------> class2\n", "class2 <--------- class1")) # test output equality self.assertEqual(message,outString)
def test_list_class(self): model = UMLModel() model.create_class("class1") model.create_class("class2") model.create_class("class3") # variables used for testing equality message = model.list_class("class5")[1] # test output equality while using the wrong class name self.assertEqual(message, "'class5' is not a valid class") # add fields to class1 model.create_field("class1", "public", "void", "a1") model.create_field("class1", "private", "int", "size") # add methods to class1 along with some parameters model.create_method("class1", "protected", "void", "setSpeed") model.create_method("class1", "public", "void", "walk") model.create_parameter("class1", "setSpeed", "int", "speed") model.create_parameter("class1", "walk", "int", "speed") model.create_parameter("class1", "walk", "double", "direction") # add relationships to class1 model.create_relationship("inheritance", "class1", "class2") model.create_relationship("aggregation", "class3", "class1") # variables used for testing equality message = model.list_class("class1")[1] outString = "".join(("Class: class1\n", "=== Fields ======================\n", "public a1: void\n", "private size: int\n", "=== Methods =====================\n", "protected setSpeed(int speed): void\n", "public walk(int speed, double direction): void\n", "=== Relationships ===============\n", "class1 ---------> class2\n", "class1 <<>>------ class3\n", "=================================")) # test output equality self.assertEqual(message,outString)