Changeset ac5b69d in sasview for test


Ignore:
Timestamp:
May 5, 2014 3:41:43 PM (6 years ago)
Author:
Jeff Krzywon <jeffery.krzywon@…>
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:
c81aa18
Parents:
0089be3
Message:

Ticket #249 fix: Saving and loading projects and analysis is now working.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/sansdataloader/test/utest_cansas.py

    r2e3b055 rac5b69d  
    55warnings.simplefilter("ignore") 
    66 
    7 import unittest 
    8 import numpy 
    97import sans.dataloader.readers.cansas_reader as cansas 
    108from sans.dataloader.loader import Loader 
     
    1210from sans.dataloader.readers.xml_reader import XMLreader 
    1311from sans.dataloader.readers.cansas_reader import Reader 
    14 from sans.dataloader.readers.cansas_constants import cansasConstants 
     12from sans.dataloader.readers.cansas_constants import CansasConstants 
    1513 
    1614import os 
     
    1816import urllib2 
    1917import StringIO 
     18import pylint as pylint 
     19import unittest 
     20import numpy 
    2021 
    2122from lxml import etree 
    2223from xml.dom import minidom 
    2324  
    24 CANSAS_FORMAT = cansasConstants.CANSAS_FORMAT 
    25 CANSAS_NS = cansasConstants.CANSAS_NS 
     25CANSAS_FORMAT = CansasConstants.CANSAS_FORMAT 
     26CANSAS_NS = CansasConstants.CANSAS_NS 
    2627     
    2728class cansas_reader(unittest.TestCase): 
     
    7273    def test_real_xml(self): 
    7374        reader = XMLreader(self.xml_valid, self.schema_1_0) 
    74         valid = reader.validateXML() 
     75        valid = reader.validate_xml() 
    7576        if valid: 
    7677            self.assertTrue(valid) 
     
    101102        filename = "isis_1_1_write_test.xml" 
    102103        xmlreader = XMLreader(self.isis_1_1, self.schema_1_1) 
    103         valid = xmlreader.validateXML() 
    104         xmlreader.setProcessingInstructions() 
     104        valid = xmlreader.validate_xml() 
     105        xmlreader.set_processing_instructions() 
    105106        self.assertTrue(valid) 
    106107        fo = open(self.isis_1_1) 
     
    126127    def test_double_trans_spectra(self): 
    127128        xmlreader = XMLreader(self.isis_1_1_doubletrans, self.schema_1_1) 
    128         self.assertTrue(xmlreader.validateXML()) 
     129        self.assertTrue(xmlreader.validate_xml()) 
    129130        reader = Loader() 
    130131        data = reader.load(self.isis_1_1_doubletrans) 
     
    146147        valid = [] 
    147148        reader1 = XMLreader(self.xml_valid, self.schema_1_0) 
    148         self.assertTrue(reader1.validateXML()) 
     149        self.assertTrue(reader1.validate_xml()) 
    149150        reader2 = XMLreader(self.xml_invalid, self.schema_1_0) 
    150         self.assertFalse(reader2.validateXML()) 
     151        self.assertFalse(reader2.validate_xml()) 
    151152        reader3 = XMLreader(self.xml_valid, self.schema_1_1) 
    152         self.assertFalse(reader3.validateXML()) 
     153        self.assertFalse(reader3.validate_xml()) 
    153154        reader4 = XMLreader(self.xml_invalid, self.schema_1_1) 
    154         self.assertFalse(reader4.validateXML()) 
     155        self.assertFalse(reader4.validate_xml()) 
    155156        reader5 = XMLreader(self.isis_1_0, self.schema_1_0) 
    156         self.assertTrue(reader5.validateXML()) 
     157        self.assertTrue(reader5.validate_xml()) 
    157158        reader6 = XMLreader(self.isis_1_1, self.schema_1_1) 
    158         self.assertTrue(reader6.validateXML()) 
     159        self.assertTrue(reader6.validate_xml()) 
    159160        reader7 = XMLreader(self.isis_1_1, self.schema_1_0) 
    160         self.assertFalse(reader7.validateXML()) 
     161        self.assertFalse(reader7.validate_xml()) 
    161162         
    162163        
    163164    def test_old_cansas_files(self): 
    164165        reader1 = XMLreader(self.cansas1d, self.schema_1_0) 
    165         self.assertTrue(reader1.validateXML()) 
     166        self.assertTrue(reader1.validate_xml()) 
    166167        file_loader = Loader() 
    167168        file1 = file_loader.load(self.cansas1d) 
    168169        reader2 = XMLreader(self.cansas1d_units, self.schema_1_0) 
    169         self.assertTrue(reader2.validateXML()) 
     170        self.assertTrue(reader2.validate_xml()) 
    170171        reader3 = XMLreader(self.cansas1d_badunits, self.schema_1_0) 
    171         self.assertTrue(reader3.validateXML()) 
     172        self.assertTrue(reader3.validate_xml()) 
    172173        reader4 = XMLreader(self.cansas1d_slit, self.schema_1_0) 
    173         self.assertTrue(reader4.validateXML()) 
     174        self.assertTrue(reader4.validate_xml()) 
    174175         
    175176     
     
    177178        filename = "isis_1_0_write_test.xml" 
    178179        xmlreader = XMLreader(self.isis_1_0, self.schema_1_0) 
    179         valid = xmlreader.validateXML() 
     180        valid = xmlreader.validate_xml() 
    180181        self.assertTrue(valid) 
    181182        reader_generic = Loader() 
     
    191192            written_data = return_data[0] 
    192193            xmlwrite = XMLreader(filename, self.schema_1_0) 
    193             valid = xmlreader.validateXML() 
     194            valid = xmlreader.validate_xml() 
    194195            self.assertTrue(valid) 
    195196            self._check_data(written_data) 
     
    198199    def test_processing_instructions(self): 
    199200        reader = XMLreader(self.isis_1_1, self.schema_1_1) 
    200         valid = reader.validateXML() 
     201        valid = reader.validate_xml() 
    201202        if valid: 
    202203            ## find the processing instructions and make into a dictionary 
    203             dic = self.getProcessingInstructions(reader) 
     204            dic = self.get_processing_instructions(reader) 
    204205            self.assertTrue(dic == {'xml-stylesheet': 'type="text/xsl" href="cansas1d.xsl" '}) 
    205206             
     
    208209             
    209210            ## take the processing instructions and put them back in 
    210             xmldoc = self.setProcessingInstructions(xmldoc, dic) 
     211            xmldoc = self.set_processing_instructions(xmldoc, dic) 
    211212            xml_output = xmldoc.toprettyxml() 
    212213             
    213214     
    214     def setProcessingInstructions(self, minidomObject, dic): 
    215         xmlroot = minidomObject.firstChild 
     215    def set_processing_instructions(self, minidom_object, dic): 
     216        xmlroot = minidom_object.firstChild 
    216217        for item in dic: 
    217             pi = minidomObject.createProcessingInstruction(item, dic[item]) 
    218             minidomObject.insertBefore(pi, xmlroot) 
    219         return minidomObject 
    220      
    221      
    222     def getProcessingInstructions(self, XMLreaderObject): 
     218            pi = minidom_object.createProcessingInstruction(item, dic[item]) 
     219            minidom_object.insertBefore(pi, xmlroot) 
     220        return minidom_object 
     221     
     222     
     223    def get_processing_instructions(self, xml_reader_object): 
    223224        dict = {} 
    224         pi = XMLreaderObject.xmlroot.getprevious() 
     225        pi = xml_reader_object.xmlroot.getprevious() 
    225226        i = 0 
    226227        while pi is not None: 
Note: See TracChangeset for help on using the changeset viewer.