Skip to content

Commit

Permalink
refs #7472. Adding tests for getGroup.
Browse files Browse the repository at this point in the history
Lots of options for using getGroup. Cover the specific 'whattoget' arguments.
  • Loading branch information
OwenArnold committed Jul 18, 2013
1 parent b4b3b51 commit 069604c
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions Code/Mantid/scripts/test/ReflectometryQuickAuxiliaryTest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import numpy
from MantidFramework import mtd
mtd.initialise()
from mantid.simpleapi import *
Expand All @@ -17,12 +18,15 @@ def test_cleanup(self):
self.assertEqual(1, len(cleaned_object_names))
self.assertEqual(True, ('tokeep' in cleaned_object_names))

DeleteWorkspace(tokeep)

def test_coAdd_ws_in_ADS(self):
inWS = CreateSingleValuedWorkspace(DataValue=1, ErrorValue=1)
quick.coAdd('inWS', 'ProvidedName')
outWS = mtd['_WProvidedName']
result = CheckWorkspacesMatch(Workspace1=inWS, Workspace2=outWS)
self.assertEquals("Success!", result)
DeleteWorkspace(outWS)

def test_coAdd_run_list(self):
originalInstrument = config.getInstrument()
Expand All @@ -49,7 +53,74 @@ def test_coAdd_run_list(self):
self.assertEquals("Success!", result)
finally:
config['default.instrument'] = originalInstrument.name()
DeleteWorkspace(a[0])
DeleteWorkspace(b[0])
DeleteWorkspace(c)
DeleteWorkspace(outWS)

def test_groupGet_instrument(self):
wsName = "TestWorkspace"
LoadISISNexus(Filename='POLREF00004699', OutputWorkspace=wsName)

expectedInstrument = "POLREF"

# Test with group workspace as input
instrument = quick.groupGet(wsName, 'inst')
self.assertEquals(expectedInstrument, instrument.getName(), "Did not fetch the instrument from ws group")

# Test with single workspace as input
instrument = quick.groupGet(mtd[wsName][0].name(), 'inst')
self.assertEquals(expectedInstrument, instrument.getName(), "Did not fetch the instrument from ws")

DeleteWorkspace(mtd[wsName])

def test_groupGet_histogram_count(self):
wsName = "TestWorkspace"
LoadISISNexus(Filename='POLREF00004699', OutputWorkspace=wsName)
expectedNHistograms = mtd[wsName][0].getNumberHistograms()

# Test with group workspace as input
nHistograms = quick.groupGet(wsName, 'wksp')
self.assertEquals(expectedNHistograms, nHistograms, "Did not fetch the n histograms from ws group")

# Test with single workspace as input
nHistograms = quick.groupGet(mtd[wsName][0].name(), 'wksp')
self.assertEquals(expectedNHistograms, nHistograms, "Did not fetch the n histograms from ws")

DeleteWorkspace(mtd[wsName])

def test_groupGet_log_single_value(self):
wsName = "TestWorkspace"
LoadISISNexus(Filename='POLREF00004699', OutputWorkspace=wsName)

expectedNPeriods = 2

# Test with group workspace as input
nPeriods = quick.groupGet(wsName, 'samp', 'nperiods')
self.assertEquals(expectedNPeriods, nPeriods, "Did not fetch the number of periods from ws group")

# Test with single workspace as input
nPeriods = quick.groupGet(mtd[wsName][0].name(), 'samp', 'nperiods')
self.assertEquals(expectedNPeriods, nPeriods, "Did not fetch the number of periods from ws")

DeleteWorkspace(mtd[wsName])

def test_groupGet_multi_value_log(self):
wsName = "TestWorkspace"
LoadISISNexus(Filename='POLREF00004699', OutputWorkspace=wsName)

# Expected start theta, taken from the last value of the time series log.
expectedStartTheta = 0.4903

# Test with group workspace as input
stheta = quick.groupGet(wsName, 'samp', 'stheta')
self.assertEquals(expectedStartTheta, round(float(stheta), 4))

# Test with single workspace as input
stheta = quick.groupGet(mtd[wsName][0].name(), 'samp', 'stheta')
self.assertEquals(expectedStartTheta, round(float(stheta), 4))

DeleteWorkspace(mtd[wsName])


if __name__ == '__main__':
Expand Down

0 comments on commit 069604c

Please sign in to comment.