]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa/core/decorator: Add skipIfNotDataVar and skipIfNotInDataVar
authorMariano Lopez <mariano.lopez@linux.intel.com>
Mon, 12 Dec 2016 10:12:15 +0000 (10:12 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 23 Jan 2017 12:03:56 +0000 (12:03 +0000)
skipIfNotDataVar will skip a test if a variable doesn't have certain value.

skipIfNotInDataVar will skip a test if a value is not in a certain variable.

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
meta/lib/oeqa/core/decorator/data.py

index fdeba9fe1d03ba863d9dfbd73d6a16b4fc789827..ff7bdd98b7fefd82d08f698b72bf3a61b376ae0d 100644 (file)
@@ -28,11 +28,45 @@ class skipIfDataVar(OETestDecorator):
     attrs = ('var', 'value', 'msg')
 
     def setUpDecorator(self):
-        msg = 'Checking if %r value is %r to skip test' % (self.var, self.value)
+        msg = ('Checking if %r value is %r to skip test' %
+               (self.var, self.value))
         self.logger.debug(msg)
         if self.case.td.get(self.var) == self.value:
             self.case.skipTest(self.msg)
 
+@registerDecorator
+class skipIfNotDataVar(OETestDecorator):
+    """
+        Skip test based on value of a data store's variable.
+
+        It will get the info of var from the data store and will
+        check it against value; if are not equal it will skip the
+        test with msg as the reason.
+    """
+
+    attrs = ('var', 'value', 'msg')
+
+    def setUpDecorator(self):
+        msg = ('Checking if %r value is not %r to skip test' %
+               (self.var, self.value))
+        self.logger.debug(msg)
+        if not self.case.td.get(self.var) == self.value:
+            self.case.skipTest(self.msg)
+
+@registerDecorator
+class skipIfNotInDataVar(OETestDecorator):
+    """
+        Skip test if value is not in data store's variable.
+    """
+
+    attrs = ('var', 'value', 'msg')
+    def setUpDecorator(self):
+        msg = ('Checking if %r value is in %r to run '
+              'the test' % (self.var, self.value))
+        self.logger.debug(msg)
+        if not self.value in self.case.td.get(self.var):
+            self.case.skipTest(self.msg)
+
 @registerDecorator
 class OETestDataDepends(OETestDecorator):
     attrs = ('td_depends',)