Add test cases for the newly introduced test decorator OETestPriority
Signed-off-by: Konrad Weihmann <[email protected]>
---
meta/lib/oeqa/core/tests/cases/priority.py | 61 +++++++++++++++
meta/lib/oeqa/core/tests/test_decorators.py | 82 ++++++++++++++++++++-
2 files changed, 142 insertions(+), 1 deletion(-)
create mode 100644 meta/lib/oeqa/core/tests/cases/priority.py
diff --git a/meta/lib/oeqa/core/tests/cases/priority.py
b/meta/lib/oeqa/core/tests/cases/priority.py
new file mode 100644
index 0000000000..cb48eb0424
--- /dev/null
+++ b/meta/lib/oeqa/core/tests/cases/priority.py
@@ -0,0 +1,61 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.core.case import OETestCase
+from oeqa.core.decorator.priority import OETestPriority
+from oeqa.core.decorator.depends import OETestDepends
+
+class PriorityTest(OETestCase):
+
+ @OETestPriority(0)
+ def testDependsBoundsLower(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ @OETestPriority(00)
+ def testDependsBoundsUpper(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ @OETestPriority(-1)
+ def testDependsBoundsLowerOff(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ @OETestPriority(100)
+ def testDependsBoundsUpperOff(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ @OETestPriority("abc")
+ def testDependsBoundsType(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ @OETestPriority(80)
+ def testPriority80(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ @OETestDepends(['testPriority80'])
+ def testPriority80plus(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ @OETestPriority(30)
+ def testPriority30(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ @OETestDepends(['testPriority30'])
+ @OETestPriority(25)
+ def testPriority25(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ @OETestDepends(['testPriority25'])
+ @OETestPriority(15)
+ def testPriority15(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ def testPriorityNoDepends(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ def testPriorityNoDepends2(self):
+ self.assertTrue(True, msg='How is this possible?')
+
+ @OETestDepends(['testPriorityNoDepends'])
+ def testPriorityDependsNoPrio(self):
+ self.assertTrue(True, msg='How is this possible?')
diff --git a/meta/lib/oeqa/core/tests/test_decorators.py
b/meta/lib/oeqa/core/tests/test_decorators.py
index b798bf7d33..5a81be1c68 100755
--- a/meta/lib/oeqa/core/tests/test_decorators.py
+++ b/meta/lib/oeqa/core/tests/test_decorators.py
@@ -11,7 +11,7 @@ import unittest
from common import setup_sys_path, TestBase
setup_sys_path()
-from oeqa.core.exception import OEQADependency
+from oeqa.core.exception import OEQADependency, OEQAException
from oeqa.core.utils.test import getCaseMethod, getSuiteCasesNames,
getSuiteCasesIDs
class TestTagDecorator(TestBase):
@@ -133,5 +133,85 @@ class TestTimeoutDecorator(TestBase):
msg = "OETestTimeout didn't restore SIGALRM"
self.assertIs(alarm_signal, signal.getsignal(signal.SIGALRM), msg=msg)
+class TestPriorityDecorator(TestBase):
+ modules = ['priority']
+
+ def test_depends_bounds_lower(self):
+ tests = ['priority.PriorityTest.testDependsBoundsLowerOff']
+ self.assertRaises(OEQAException, self._testLoader,
modules=self.modules, tests=tests)
+
+ def test_depends_bounds_upper(self):
+ tests = ['priority.PriorityTest.testDependsBoundsUpperOff']
+ self.assertRaises(OEQAException, self._testLoader,
modules=self.modules, tests=tests)
+
+ def test_depends_bounds_type(self):
+ tests = ['priority.PriorityTest.testDependsBoundsType']
+ self.assertRaises(OEQAException, self._testLoader,
modules=self.modules, tests=tests)
+
+ def test_depends_bounds(self):
+ tests = ['priority.PriorityTest.testDependsBoundsLower',
+ 'priority.PriorityTest.testDependsBoundsUpper',
+ ]
+ try:
+ tc = self._testLoader(modules=self.modules, tests=tests)
+ test_loaded = getSuiteCasesIDs(tc.suites)
+
+ self.assertEquals(test_loaded, tests, msg="Tests are loaded in the
correct order")
+ except OEQAException as e:
+ self.fail(msg="Exception while loaded test suite: %s" % e)
+
+ def test_depends_nodecorator(self):
+ tests = [
+ 'priority.PriorityTest.testPriorityNoDepends',
+ 'priority.PriorityTest.testPriorityNoDepends2',
+ ]
+ try:
+ tc = self._testLoader(modules=self.modules, tests=tests)
+ test_loaded = getSuiteCasesIDs(tc.suites)
+
+ self.assertEquals(test_loaded, tests, msg="Tests are loaded in the
correct order")
+ except OEQAException as e:
+ self.fail(msg="Exception while loaded test suite: %s" % e)
+
+ def test_depends_nopriority(self):
+ tests = [
+ 'priority.PriorityTest.testPriorityDependsNoPrio',
+ 'priority.PriorityTest.testPriorityNoDepends',
+ ]
+ expected_order = [
+ 'priority.PriorityTest.testPriorityNoDepends',
+ 'priority.PriorityTest.testPriorityDependsNoPrio',
+ ]
+ try:
+ tc = self._testLoader(modules=self.modules, tests=tests)
+ test_loaded = getSuiteCasesIDs(tc.suites)
+
+ self.assertEquals(test_loaded, expected_order, msg="Tests are
loaded in the correct order")
+ except OEQAException as e:
+ self.fail(msg="Exception while loaded test suite: %s" % e)
+
+ def test_depends_order(self):
+ tests = [
+ 'priority.PriorityTest.testPriority15',
+ 'priority.PriorityTest.testPriority25',
+ 'priority.PriorityTest.testPriority30',
+ 'priority.PriorityTest.testPriority80',
+ 'priority.PriorityTest.testPriority80plus',
+ ]
+ expected_order = [
+ 'priority.PriorityTest.testPriority30',
+ 'priority.PriorityTest.testPriority25',
+ 'priority.PriorityTest.testPriority15',
+ 'priority.PriorityTest.testPriority80',
+ 'priority.PriorityTest.testPriority80plus',
+ ]
+ try:
+ tc = self._testLoader(modules=self.modules, tests=tests)
+ test_loaded = getSuiteCasesIDs(tc.suites)
+
+ self.assertEquals(test_loaded, expected_order, msg="Tests are
loaded in the correct order")
+ except OEQAException as e:
+ self.fail(msg="Exception while loaded test suite: %s" % e)
+
if __name__ == '__main__':
unittest.main()
--
2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#147320):
https://lists.openembedded.org/g/openembedded-core/message/147320
Mute This Topic: https://lists.openembedded.org/mt/80137094/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-