def test_write_attributes_no_attribute(filename, element_factory): """Test writing pass when no attributes.""" book = element_factory.create(UML.Class) write_attributes(book, filename) assert filename.data == " pass\n\n"
def test_write_attributes_no_name(filename, element_factory): """Test writing pass when attribute has no name.""" book = element_factory.create(UML.Class) book.ownedAttribute = element_factory.create(UML.Property) write_attributes(book, filename) assert filename.data == " pass\n\n"
def test_write_attributes_with_operations(filename, element_factory): """Test writing an attribute for an operation.""" library = element_factory.create(UML.Class) library.ownedOperation = element_factory.create(UML.Operation) library.ownedOperation[0].name = "open" write_attributes(library, filename) assert filename.data == " open: operation\n"
def test_write_attributes_for_enumeration(filename, element_factory): """Test writing an attribute for an enumeration.""" book = element_factory.create(UML.Class) book.ownedAttribute = element_factory.create(UML.Property) book.ownedAttribute[0].name = "duration" book.ownedAttribute[0].typeValue = "loanDurationKind" write_attributes(book, filename) assert filename.data == " duration: enumeration\n"
def test_write_attributes_for_attribute(filename, element_factory): """Test writing a normal attribute.""" book = element_factory.create(UML.Class) book.ownedAttribute = element_factory.create(UML.Property) book.ownedAttribute[0].name = "title" book.ownedAttribute[0].typeValue = "str" write_attributes(book, filename) assert filename.data == " title: attribute[str]\n"
def test_write_attributes_for_relation_many(filename, element_factory): """Test writing an attribute with upper value of any.""" library = element_factory.create(UML.Class) library.ownedAttribute = element_factory.create(UML.Property) library.ownedAttribute[0].name = "books" library.ownedAttribute[0].typeValue = "Book" library.ownedAttribute[0].upperValue = "*" write_attributes(library, filename) assert filename.data == " books: relation_many[Book]\n"
def test_write_attributes_for_relation_one(filename, element_factory): """Test writing an attribute with upper value of one.""" patron = element_factory.create(UML.Class) patron.ownedAttribute = element_factory.create(UML.Property) patron.ownedAttribute[0].name = "libraryCard" patron.ownedAttribute[0].typeValue = "Card" patron.ownedAttribute[0].upperValue = "1" write_attributes(patron, filename) assert filename.data == " libraryCard: relation_one[Card]\n"