TestCenter Reference
GenericTest.py
Go to the documentation of this file.
2# Copyright 2013, MeVis Medical Solutions AG
3#
4# The user may use this file in accordance with the license agreement provided with
5# the Software or, alternatively, in accordance with the terms contained in a
6# written agreement between the user and MeVis Medical Solutions AG.
7#
8# For further information use the contact form at https://www.mevislab.de/contact
9#
10
11from unittest.mock import patch
12import unittest
13
14from TestSupport.Generic import *
15import Meta
16import Formal
17import FormalMacroModule
18
19class SharedTest(unittest.TestCase):
20
21 def testOmitBoth(self):
22 with patch('mevis.MLAB.moduleInfo') as moduleInfoMock:
23 moduleName = "dummyModuleName"
24 moduleInfoMock.return_value = {TESTS_TO_OMIT_TAG: " ".join([FORMAL_TEST_IDENTIFIER, META_TEST_IDENTIFIER])}
25 omittedTests = getTestsToOmit(moduleName)
26
27 self.assertListEqual([FORMAL_TEST_IDENTIFIER, META_TEST_IDENTIFIER], omittedTests)
28 moduleInfoMock.assert_called_once_with(moduleName)
29
30 def testOmitNothing(self):
31 with patch('mevis.MLAB.moduleInfo') as moduleInfoMock:
32 moduleName = "dummyModuleName"
33 moduleInfoMock.return_value = {}
34 omittedTests = getTestsToOmit(moduleName)
35
36 self.assertListEqual([], omittedTests)
37 moduleInfoMock.assert_called_once_with(moduleName)
38
39 def testOmitAll(self):
40 with patch('mevis.MLAB.moduleInfo') as moduleInfoMock:
41 moduleName = "dummyModuleName"
42 moduleInfoMock.return_value = {TESTS_TO_OMIT_TAG: ALL_TESTS_IDENTIFIER}
43 omittedTests = getTestsToOmit(moduleName)
44
45 self.assertIn(ALL_TESTS_IDENTIFIER, omittedTests)
46 moduleInfoMock.assert_called_once_with(moduleName)
47
48 def testIsOmitted(self):
49 with patch('TestSupport.Generic.getTestsToOmit') as omitMock:
50 moduleName = "DummyModuleName"
51 #recognize if in list
52 omitMock.return_value = [FORMAL_TEST_IDENTIFIER, META_TEST_IDENTIFIER]
53 omitted = isTestOmitted(moduleName, FORMAL_TEST_IDENTIFIER)
54 self.assertTrue(omitted)
55 #counter-check if method in tests works as well
56 self.assertFalse(Formal.testModule(moduleName))
57 self.assertFalse(FormalMacroModule.testModule(moduleName))
58 self.assertFalse(Meta.testModule(moduleName))
59
60 #skip also if all tests should be skipped
61 omitMock.return_value = [ALL_TESTS_IDENTIFIER]
62 omitted = isTestOmitted(moduleName, FORMAL_TEST_IDENTIFIER)
63 self.assertTrue(omitted)
64 #counter-check if method in tests works as well
65 self.assertFalse(Formal.testModule(moduleName))
66 self.assertFalse(FormalMacroModule.testModule(moduleName))
67 self.assertFalse(Meta.testModule(moduleName))
68
69 #skip not if not in list
70 omitMock.return_value = []
71 omitted = isTestOmitted(moduleName, FORMAL_TEST_IDENTIFIER)
72 self.assertFalse(omitted)
73 #counter-check if method in tests works as well
74 self.assertTrue(Formal.testModule(moduleName))
75 self.assertTrue(FormalMacroModule.testModule(moduleName))
76 self.assertTrue(Meta.testModule(moduleName))
77
78 if __name__ == "__main__":
79 #import sys;sys.argv = ['', 'Test.testName']
80 unittest.main()
getTestsToOmit(moduleName)
Definition Generic.py:24
isTestOmitted(moduleName, testIdentifier)
Definition Generic.py:49