Changeset 0a6e097 in sasview for src


Ignore:
Timestamp:
May 1, 2017 4:20:03 AM (8 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
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
Children:
d48cc19
Parents:
28a09b0
Message:

Unit tests for the GSC fixed, additional files uploaded

Location:
src/sas/qtgui
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Calculators/UnitTesting/GenericScatteringCalculatorTest.py

    r28a09b0 r0a6e097  
    1616from UnitTesting.TestUtils import QtSignalSpy 
    1717from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 
    18 from GenericScatteringCalculator import GenericScatteringCalculator 
    19 from GenericScatteringCalculator import Plotter3D 
     18from sas.qtgui.Calculators.GenericScatteringCalculator import GenericScatteringCalculator 
     19from sas.qtgui.Calculators.GenericScatteringCalculator import Plotter3D 
    2020 
    2121from sas.sasgui.guiframe.data_manager import DataManager 
    22 from GuiManager import GuiManager 
    23 from sas.qtgui.GuiUtils import * 
     22from sas.qtgui.MainWindow.GuiManager import GuiManager 
     23from sas.qtgui.Utilities.GuiUtils import * 
    2424from sas.sascalc.calculator import sas_gen 
    2525 
     
    173173        Load sld data and check modifications of GUI 
    174174        """ 
    175         filename = "../../../sasview/test/save_states/sld_file.sld" 
     175        filename = os.path.join("UnitTesting", "sld_file.sld") 
    176176        QtGui.QFileDialog.getOpenFileName = MagicMock(return_value=filename) 
    177177        self.widget.loadFile() 
     
    205205        # Mx,y,z x,y,znodes and x,y,zstepsize buttons 
    206206        self.assertFalse(self.widget.txtMx.isEnabled()) 
    207         self.assertEqual(self.widget.txtMx.text(), '8.0795e-07') 
     207        self.assertAlmostEqual(float(self.widget.txtMx.text()), 8.0795e-07, 4) 
    208208        self.assertFalse(self.widget.txtMy.isEnabled()) 
    209         self.assertEqual(self.widget.txtMy.text(), '8.0795e-07') 
     209        self.assertAlmostEqual(float(self.widget.txtMy.text()), 8.0795e-07, 4) 
    210210        self.assertFalse(self.widget.txtMz.isEnabled()) 
    211         self.assertEqual(self.widget.txtMz.text(), '3.1739e-07') 
     211        self.assertAlmostEqual(float(self.widget.txtMz.text()), 3.1739e-07, 4) 
    212212        self.assertTrue(self.widget.txtNucl.isEnabled()) 
    213213        self.assertEqual(self.widget.txtNucl.text(), '0') 
     
    236236        Load pdb data and check modifications of GUI 
    237237        """ 
    238         filename = "diamdsml.pdb" 
     238        filename = os.path.join("UnitTesting", "diamdsml.pdb") 
     239 
    239240        QtGui.QFileDialog.getOpenFileName = MagicMock(return_value=filename) 
    240241        self.widget.loadFile() 
     
    275276        self.assertEqual(self.widget.txtMz.text(), '0') 
    276277        self.assertFalse(self.widget.txtNucl.isEnabled()) 
    277         self.assertEqual(self.widget.txtNucl.text(), '7.0003e-06') 
     278        self.assertAlmostEqual(float(self.widget.txtNucl.text()), 7.0003e-06, 4) 
    278279 
    279280        self.assertFalse(self.widget.txtXnodes.isEnabled()) 
     
    298299        Load omf data and check modifications of GUI 
    299300        """ 
    300         filename = "../../../sasview/test/1d_data/A_Raw_Example-1.omf" 
     301        filename = os.path.join("UnitTesting", "A_Raw_Example-1.omf") 
     302 
    301303        QtGui.QFileDialog.getOpenFileName = MagicMock(return_value=filename) 
    302304        self.widget.loadFile() 
     
    325327        # Mx,y,z x,y,znodes and x,y,zstepsize buttons 
    326328        self.assertFalse(self.widget.txtMx.isEnabled()) 
    327         self.assertEqual(self.widget.txtMx.text(), '7.855e-09') 
     329        self.assertAlmostEqual(float(self.widget.txtMx.text()), 7.855e-09, 4) 
    328330        self.assertFalse(self.widget.txtMy.isEnabled()) 
    329         self.assertEqual(self.widget.txtMy.text(), '4.5169e-08') 
     331        self.assertAlmostEqual(float(self.widget.txtMy.text()), 4.517e-08, 4) 
    330332        self.assertFalse(self.widget.txtMz.isEnabled()) 
    331         self.assertEqual(self.widget.txtMz.text(), '9.9511e-10') 
     333        self.assertAlmostEqual(float(self.widget.txtMz.text()), 9.9511e-10, 4) 
    332334        self.assertTrue(self.widget.txtNucl.isEnabled()) 
    333335        self.assertEqual(self.widget.txtNucl.text(), '0') 
     
    364366        """ 
    365367        # load data 
    366         filename = "diamdsml.pdb" 
     368        filename = os.path.join("UnitTesting", "diamdsml.pdb") 
     369 
    367370        QtGui.QFileDialog.getOpenFileName = MagicMock(return_value=filename) 
    368371        self.widget.loadFile() 
     
    383386        """ 
    384387        self.assertFalse(self.widget.cmdDraw.isEnabled()) 
    385         # filename = "../../../sasview/test/upcoming_formats/dna.pdb" 
    386         filename = "diamdsml.pdb" 
     388        filename = os.path.join("UnitTesting", "diamdsml.pdb") 
    387389        QtGui.QFileDialog.getOpenFileName = MagicMock(return_value=filename) 
    388390        self.widget.loadFile() 
     
    403405        Test Save feature to .sld file 
    404406        """ 
    405         filename = "../../../sasview/test/save_states/sld_file.sld" 
     407        filename = os.path.join("UnitTesting", "sld_file.sld") 
     408 
    406409        QtGui.QFileDialog.getOpenFileName = MagicMock(return_value=filename) 
    407410        self.widget.loadFile() 
     
    409412        time.sleep(0.1) 
    410413 
    411         filename1 = "../../../sasview/test/save_states/test" 
     414        filename1 = "test" 
    412415        QtGui.QFileDialog.getSaveFileName = MagicMock(return_value=filename1) 
    413416 
     
    417420        self.assertTrue(os.path.getsize(filename1 + '.sld') > 0) 
    418421 
    419         os.remove("../../../sasview/test/save_states/test.sld") 
     422        os.remove("test.sld") 
    420423 
    421424 
Note: See TracChangeset for help on using the changeset viewer.