-
Notifications
You must be signed in to change notification settings - Fork 122
/
WorkspacePropertiesTest.py
68 lines (54 loc) · 2.93 KB
/
WorkspacePropertiesTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Tests the construction of the various workspace
property types
"""
import unittest
import testhelpers
from mantid.api import (WorkspaceProperty, WorkspaceGroupProperty, MatrixWorkspaceProperty,
IEventWorkspaceProperty, ITableWorkspaceProperty,
IMDWorkspaceProperty, IMDHistoWorkspaceProperty, IMDEventWorkspaceProperty,
PropertyMode, LockMode)
from mantid.kernel import Direction, Property
class WorkspacePropertiesTest(unittest.TestCase):
def _do_test(self, classtype):
self.assertTrue(issubclass(WorkspaceGroupProperty, Property))
self._do_construction_with_name_default_direction(classtype)
self._do_construction_with_name_default_direction_optional(classtype)
def _do_construction_with_name_default_direction(self, classtype):
prop = classtype("NoValidation", "test", Direction.Output)
self.assertTrue(isinstance(prop, classtype))
self.assertEquals("NoValidation", prop.name)
self.assertEquals(Direction.Output, prop.direction)
self.assertEquals("test", prop.valueAsStr)
def _do_construction_with_name_default_direction_optional(self, classtype):
prop = classtype("IsOptional", "test", Direction.Output, PropertyMode.Optional)
self.assertTrue(isinstance(prop, classtype))
self.assertEquals("IsOptional", prop.name)
self.assertEquals(Direction.Output, prop.direction)
self.assertTrue(prop.isOptional())
self.assertEquals("test", prop.valueAsStr)
def _do_construction_with_name_default_direction_optional_no_locking(self, classtype):
prop = classtype("DoesNotLock", "test", Direction.Output, PropertyMode.Optional, LockMode.NoLock)
self.assertTrue(isinstance(prop, classtype))
self.assertEquals("DoesNotLock", prop.name)
self.assertEquals(Direction.Output, prop.direction)
self.assertTrue(prop.isOptional())
self.assertFalse(prop.isLocking())
self.assertEquals("test", prop.valueAsStr)
def test_WorkspaceProperty_can_be_instantiated(self):
self._do_test(WorkspaceProperty)
def test_WorkspaceGroupProperty_can_be_instantiated(self):
self._do_test(WorkspaceGroupProperty)
def test_MatrixWorkspaceProperty_can_be_instantiated(self):
self._do_test(MatrixWorkspaceProperty)
def test_IEventWorkspaceProperty_can_be_instantiated(self):
self._do_test(IEventWorkspaceProperty)
def test_ITableWorkspaceProperty_can_be_instantiated(self):
self._do_test(ITableWorkspaceProperty)
def test_IMDHistoWorkspaceProperty_can_be_instantiated(self):
self._do_test(IMDHistoWorkspaceProperty)
def test_IMDEventWorkspaceProperty_can_be_instantiated(self):
self._do_test(IMDEventWorkspaceProperty)
def test_IMDWorkspaceProperty_can_be_instantiated(self):
self._do_test(IMDWorkspaceProperty)
if __name__ == "__main__":
unittest.main()