def test_gbxml_remove_attribute(self): g=Gbxml() e=g.root() g.remove_attribute(e,'temperatureUnit') d=g.attributes(e) check={'lengthUnit': 'Meters', 'areaUnit': 'SquareMeters', 'volumeUnit': 'CubicMeters', 'useSIUnitsForResults': 'true', 'version': '0.37'} self.assertEqual(d,check)
def test_gbxml_xpath(self): g=Gbxml(config.xml,config.xsd) st='/gbxml:gbXML' l=g.xpath(g.root(),st) n=len(l) check=1 self.assertEqual(n,check)
def test_gbxml_set_attribute(self): g=Gbxml() e=g.root() e=g.set_attribute(e,'temperatureUnit','K') st=e.get('temperatureUnit') check='K' self.assertEqual(st,check)
def test_gbxml_set_text(self): g=Gbxml() e=g.add_element(g.root(),'Campus') e=g.add_element(e,'Name') e=g.set_text(e,'MyCampus') st=e.text check='MyCampus' self.assertEqual(st,check)
def test_gbxml_validate(self): g=Gbxml(config.xml,config.xsd) b=g.validate() check=True self.assertEqual(b,check) g._ElementTree=etree.parse(StringIO('<a><c></c></a>')) b=g.validate() check=False self.assertEqual(b,check)
def test_gbxml_remove_zone(self): g=Gbxml(config.xml,config.xsd) g.remove_zone('ZONE_1') l=g.elements('Zone') check=0 self.assertEqual(len(l),check) space=g.elements('Space')[0] check=None self.assertEqual(space.get('zoneIdRef'),check)
def test_gbxml_add_zone(self): g=Gbxml() campus=g.add_element(g.root(),'Campus') building=g.add_element(campus,'Building') space=g.add_element(building,'Space') space.set('id','space-1') g.add_zone('zone-1','space-1') l=g.elements('Zone') check=1 self.assertEqual(len(l),check) st=space.get('zoneIdRef') check='zone-1' self.assertEqual(st,check)
def test_gbxml_remove_element(self): g=Gbxml(config.xml,config.xsd) g.remove_element('campus-1') l=g.elements('Campus') check=[] self.assertEqual(l,check)
def test_gbxml_add_element(self): g=Gbxml() g.add_element(g.root(),'Campus') n=len(g.elements()) check=2 self.assertEqual(n,check)
def test_gbxml_xmlstring(self): g=Gbxml(config.xml,config.xsd) st=g.xmlstring() check="""<gbXML xmlns="http://www.gbxml.org/schema" temperatureUnit="C" lengthUnit="Meters" areaUnit="SquareMeters" volumeUnit="CubicMeters" useSIUnitsForResults="true" version="0.37"> <Campus id="campus-1">""" self.assertEqual(st[0:200],check)
def test_gbxml_descendent_elements(self): g=Gbxml(config.xml,config.xsd) l=g.descendent_elements(g.root(),label='Building') st=g.label(l[0]) check='Building' self.assertEqual(st,check)
def test_gbxml_child_elements(self): g=Gbxml(config.xml,config.xsd) l=g.child_elements(g.root(),label='Campus') st=g.label(l[0]) check='Campus' self.assertEqual(st,check)
def test_gbxml_text(self): g=Gbxml(config.xml,config.xsd) e=g.elements(label='Name')[0] st=g.text(e) check='detached_house' self.assertEqual(st,check)
def test_gbxml_label(self): g=Gbxml() e=g.root() st=g.label(e) check='gbXML' self.assertEqual(st,check)
def test_gbxml_element(self): g=Gbxml(config.xml,config.xsd) e=g.element(id='campus-1') st=g.label(e) check='Campus' self.assertEqual(st,check)
def test_gbxml_elements(self): g=Gbxml(config.xml,config.xsd) l=g.elements() n=len(l) check=3953 self.assertEqual(n,check)