def test_basic(self): field = Field(var='test') self.assertEqual('text-single', field.fieldType) self.assertEqual('test', field.var) element = field.toElement() self.assertTrue(domish.IElement.providedBy(element)) self.assertEquals('field', element.name) self.assertEquals(NS_X_DATA, element.uri) self.assertEquals('text-single', element['type']) self.assertEquals('test', element['var']) self.assertEquals([], element.children)
def test_fromElementValue(self): element = domish.Element((NS_X_DATA, 'field')) element.addElement("value", content="text") field = Field.fromElement(element) self.assertEquals('text', field.value)
def test_fromElementNoType(self): element = domish.Element((NS_X_DATA, 'field')) field = Field.fromElement(element) self.assertEquals(None, field.fieldType)
def test_fromElementType(self): element = domish.Element((NS_X_DATA, 'field')) element['type'] = 'fixed' field = Field.fromElement(element) self.assertEquals('fixed', field.fieldType)
def test_noFieldName(self): field = Field() self.assertRaises(FieldNameRequiredError, field.toElement)