Changeset 3a0ce4f in sasview


Ignore:
Timestamp:
Dec 13, 2016 10:00:06 AM (8 years ago)
Author:
wojciech
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:
debf5c3
Parents:
0532d7c1
Message:

Added a few unit tests

Location:
src/sas/qtgui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/SlitSizeCalculator.py

    r0532d7c1 r3a0ce4f  
    88 
    99import os 
     10import sys 
    1011 
    1112class SlitSizeCalculator(QtGui.QDialog, Ui_SlitSizeCalculator): 
     
    9293            raise RuntimeError, msg 
    9394 
    94         if isinstance(data, Data2D): 
     95        if isinstance(data, Data2D) or data.__class__.__name__ == 'Data2D': 
    9596            msg = "Slit Length cannot be computed for 2D Data" 
    9697            raise Exception, msg 
  • src/sas/qtgui/UnitTesting/SlitSizeCalculatorTest.py

    r0532d7c1 r3a0ce4f  
    1010 
    1111from SlitSizeCalculator import SlitSizeCalculator 
    12 from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator as calculator 
    1312from sas.sascalc.dataloader.loader import Loader 
    1413 
     
    3938        self.widget.onHelp() 
    4039 
    41     def testComputeSlit(self): 
     40    def testCalculateSlitSize(self): 
    4241        """ User entered compound calculations and subsequent reset""" 
    4342 
     
    4544        loader = Loader() 
    4645        data = loader.load(filename) 
    47         # Push Compute with the left mouse button 
    48         cal = calculator() 
    49         cal.set_data(x = data.x, y = data.y) 
    50         slitlength = cal.calculate_slit_length() 
    5146 
     47        self.widget.calculateSlitSize(data) 
    5248        # The value "5.5858" was obtained by manual calculation. 
    5349        # It turns out our slit length is FWHM/2 
    54         self.assertAlmostEqual(slitlength,5.5858/2, 3) 
     50        self.assertAlmostEqual(float(self.widget.slit_length_out.text()), 5.5858/2, 3) 
     51 
     52    def testCalculateSlitSize2D(self): 
     53        """ User entered compound calculations and subsequent reset""" 
     54 
     55        #TODO: Test for 2D and check if exception is being raised 
     56        filename = "beam_profile.DAT" 
     57        loader = Loader() 
     58        data = loader.load(filename) 
     59 
     60        self.widget.calculateSlitSize(data) 
     61        # The value "5.5858" was obtained by manual calculation. 
     62        # It turns out our slit length is FWHM/2 
     63        self.assertAlmostEqual(float(self.widget.slit_length_out.text()), 5.5858/2, 3) 
     64 
     65    # def testDataEntryNumbers(self): 
     66    #      """ User entered compound calculations and subsequent reset""" 
     67    # 
     68    #      self.widget.data_file.clear() 
     69    #      self.widget.data_file.insert("beam profile.DAT") 
     70    #      # 
     71    #      # Push Compute with the left mouse button 
     72    #      computeButton = self.widget.computeButton 
     73    #      QTest.mouseClick(computeButton, Qt.LeftButton) 
     74    #      self.assertEqual(self.widget.lengthscale_out.text(), '6.283') 
    5575 
    5676    def testBrowseButton(self): 
Note: See TracChangeset for help on using the changeset viewer.