def testProtectedCreation(self): pve: PyutVisibilityEnum = PyutVisibilityEnum('#') expectedValue: PyutVisibilityEnum = PyutVisibilityEnum.PROTECTED actualValue: PyutVisibilityEnum = pve self.assertEqual(expectedValue, actualValue, 'Creation not creating correct value')
def testPrivateCreation(self): pve: PyutVisibilityEnum = PyutVisibilityEnum('-') expectedValue: PyutVisibilityEnum = PyutVisibilityEnum.PRIVATE actualValue: PyutVisibilityEnum = pve self.assertEqual(expectedValue, actualValue, 'Creation not creating correct value')
def testPublicCreation(self): pve: PyutVisibilityEnum = PyutVisibilityEnum('+') expectedValue: PyutVisibilityEnum = PyutVisibilityEnum.PUBLIC actualValue: PyutVisibilityEnum = pve self.assertEqual(expectedValue, actualValue, 'Creation not creating correct value')
def _getMethods(self, xmlClass: Element) -> PyutMethods: """ Converts XML methods to `PyutMethod`s Args: xmlClass: A DOM element that is a UML Class Returns: A list of `PyutMethod`s associated with the class """ allMethods: PyutMethods = cast(PyutMethods, []) for xmlMethod in xmlClass.getElementsByTagName( PyutXmlConstants.ELEMENT_MODEL_METHOD): pyutMethod: PyutMethod = PyutMethod( xmlMethod.getAttribute(PyutXmlConstants.ATTR_NAME)) strVis: str = xmlMethod.getAttribute( PyutXmlConstants.ATTR_VISIBILITY) vis: PyutVisibilityEnum = PyutVisibilityEnum(strVis) pyutMethod.setVisibility(visibility=vis) returnElt: Element = xmlMethod.getElementsByTagName( PyutXmlConstants.ELEMENT_MODEL_RETURN)[0] pyutMethod.setReturns( returnElt.getAttribute(PyutXmlConstants.ATTR_TYPE)) # # Code supports multiple modifiers, but the dialog allows input of only one # modifiers: NodeList = xmlMethod.getElementsByTagName( PyutXmlConstants.ELEMENT_MODEL_MODIFIER) for xmlModifier in modifiers: xmlModifier: Element = cast(Element, xmlModifier) modName: str = xmlModifier.getAttribute( PyutXmlConstants.ATTR_NAME) pyutModifier: PyutModifier = PyutModifier(modName) pyutMethod.addModifier(pyutModifier) methodParameters = [] for xmlParam in xmlMethod.getElementsByTagName( PyutXmlConstants.ELEMENT_MODEL_PARAM): methodParameters.append(self._getParam(xmlParam)) pyutMethod.setParams(methodParameters) allMethods.append(pyutMethod) return allMethods
def _getFields(self, Class): """ To extract fields form Class. @since 1.0 @author Deve Roux <*****@*****.**> """ # for class fields allFields = [] for Field in Class.getElementsByTagName("Field"): aField = PyutField() # aField.setVisibility(Field.getAttribute('visibility')) vis: PyutVisibilityEnum = PyutVisibilityEnum(Field.getAttribute('visibility')) aField.setVisibility(vis) Param = Field.getElementsByTagName("Param")[0] if Param.hasAttribute('defaultValue'): aField.setDefaultValue(Param.getAttribute('defaultValue')) aField.setName(Param.getAttribute('name')) aField.setType(Param.getAttribute('type')) allFields.append(aField) return allFields