Changeset ea67541 in sasview for test/sansdataloader
- Timestamp:
- Apr 3, 2014 3:22:58 AM (11 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- caf273b
- Parents:
- 307fa4f
- Location:
- test/sansdataloader/test
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
test/sansdataloader/test/isis_1_0_write_test.xml
rc6ca23d rea67541 1 1 <?xml version="1.0" ?> 2 <?xml-stylesheet type="text/xsl" href="cansasxml-html.xsl" ?> 2 3 <SASroot version="1.0" xmlns="cansas1d/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="cansas1d/1.0 http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd"> 3 4 <SASentry> -
test/sansdataloader/test/isis_1_1_write_test.xml
rc6ca23d rea67541 1 1 <?xml version="1.0" ?> 2 <?xml-stylesheet type="text/xsl" href="cansas xml-html.xsl"?>2 <?xml-stylesheet type="text/xsl" href="cansas1d.xsl" ?> 3 3 <SASroot version="1.1" xmlns="urn:cansas1d:1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:cansas1d:1.1 http://www.cansas.org/formats/1.1/cansas1d.xsd"> 4 4 <SASentry> -
test/sansdataloader/test/utest_cansas.py
rc6ca23d rea67541 20 20 21 21 from lxml import etree 22 import xml.dom.minidom22 from xml.dom import minidom 23 23 24 24 CANSAS_FORMAT = cansasConstants.CANSAS_FORMAT … … 50 50 name = self.get_number_of_entries(dictionary, name, i) 51 51 return name 52 52 53 53 54 54 def test_xml_validate(self): … … 82 82 self.assertTrue(data.title == "TK49 c10_SANS") 83 83 self.assertTrue(data.x.size == 138) 84 self.assertTrue(len(data.meta_data) == 2)84 self.assertTrue(len(data.meta_data) == 3) 85 85 self.assertTrue(data.detector[0].distance_unit == "mm") 86 86 self.assertTrue(data.detector[1].distance_unit == "mm") … … 90 90 self.assertTrue(data.detector[1].distance == 4145.02) 91 91 self.assertTrue(data.process[0].name == "Mantid generated CanSAS1D XML") 92 self.assertTrue(data.meta_data["xmlpreprocess"]["xml-stylesheet"] != None) 92 93 93 94 … … 155 156 self.assertFalse(reader7.validateXML()) 156 157 157 158 158 159 def test_old_cansas_files(self): 159 160 reader1 = XMLreader(self.cansas1d, self.schema_1_0) 160 161 self.assertTrue(reader1.validateXML()) 162 file_loader = Loader() 163 file1 = file_loader.load(self.cansas1d) 161 164 reader2 = XMLreader(self.cansas1d_units, self.schema_1_0) 162 165 self.assertTrue(reader2.validateXML()) … … 166 169 self.assertTrue(reader4.validateXML()) 167 170 168 169 171 def test_save_cansas_v1_0(self): 170 172 filename = "isis_1_0_write_test.xml" … … 186 188 self._check_data(written_data) 187 189 188 190 191 def test_processing_instructions(self): 192 reader = XMLreader(self.isis_1_1, self.schema_1_1) 193 valid = reader.validateXML() 194 if valid: 195 ## find the processing instructions and make into a dictionary 196 dic = self.getProcessingInstructions(reader) 197 self.assertTrue(dic == {'xml-stylesheet': 'type="text/xsl" href="cansas1d.xsl" '}) 198 199 xml = "<test><a><b><c></c></b></a></test>" 200 xmldoc = minidom.parseString(xml) 201 202 ## take the processing instructions and put them back in 203 xmldoc = self.setProcessingInstructions(xmldoc, dic) 204 xml_output = xmldoc.toprettyxml() 205 206 207 def setProcessingInstructions(self, minidomObject, dic): 208 xmlroot = minidomObject.firstChild 209 for item in dic: 210 pi = minidomObject.createProcessingInstruction(item, dic[item]) 211 minidomObject.insertBefore(pi, xmlroot) 212 return minidomObject 213 214 215 def getProcessingInstructions(self, XMLreaderObject): 216 dict = {} 217 pi = XMLreaderObject.xmlroot.getprevious() 218 i = 0 219 while pi is not None: 220 attr = {} 221 pi_name = "" 222 pi_string = etree.tostring(pi) 223 if isinstance(pi_string, str): 224 pi_string = pi_string.replace("<?", "").replace("?>", "") 225 split = pi_string.split(" ", 1) 226 pi_name = split[0] 227 attr = split[1] 228 dict[pi_name] = attr 229 pi = pi.getprevious() 230 return dict 231 189 232 if __name__ == '__main__': 190 233 unittest.main() -
test/sansdataloader/test/write_test.xml
r75eeb425 rea67541 1 1 <?xml version="1.0" ?> 2 <?xml-stylesheet type="text/xsl" href="example.xsl" ?> 2 3 <SASroot version="1.0" xmlns="cansas1d/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="cansas1d/1.0 http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd"> 3 4 <SASentry>
Note: See TracChangeset
for help on using the changeset viewer.