コード例 #1
0
class ScenarioOperatorParamterTest(unittest.TestCase):
    """ Test CronParameter
    """

    def setUp(self):
        """ Create a Cron Parameter object
        """
        logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
        self._obj = ComparisonOperatorParameter(log=logging)
        self._triggered = False

    def tearDown(self):
        """ Destroy cron object
        """
        del self._obj
        self._triggered = False

    def triggered(self, payload=None):
        """ Called when the trigger is called """
        self._trigger = True

    def test_fill_with_equal(self):
        """ Test fill method with an equal
        """
        # Test without cron expression
        parameters = {"operator": "=="}
        self._obj.fill(params=parameters)
        self.assertTrue(self._obj.evaluate())

    def test_fill_with_bad(self):
        """ Test fill method with a bad operator
        """
        # Test without cron expression
        parameters = {"operator": "bad"}
        self.assertRaises(ValueError, self._obj.fill, parameters)
コード例 #2
0
 def setUp(self):
     """ Create a Cron Parameter object
     """
     logging.basicConfig(format='%(levelname)s:%(message)s',
                         level=logging.DEBUG)
     self._obj = ComparisonOperatorParameter(log=logging)
     self._triggered = False
コード例 #3
0
class ScenarioOperatorParamterTest(unittest.TestCase):
    """ Test CronParameter
    """
    def setUp(self):
        """ Create a Cron Parameter object
        """
        logging.basicConfig(format='%(levelname)s:%(message)s',
                            level=logging.DEBUG)
        self._obj = ComparisonOperatorParameter(log=logging)
        self._triggered = False

    def tearDown(self):
        """ Destroy cron object
        """
        del self._obj
        self._triggered = False

    def triggered(self, payload=None):
        """ Called when the trigger is called """
        self._trigger = True

    def test_fill_with_equal(self):
        """ Test fill method with an equal
        """
        # Test without cron expression
        parameters = {"operator": "=="}
        self._obj.fill(params=parameters)
        self.assertTrue(self._obj.evaluate())

    def test_fill_with_bad(self):
        """ Test fill method with a bad operator
        """
        # Test without cron expression
        parameters = {"operator": "bad"}
        self.assertRaises(ValueError, self._obj.fill, parameters)
コード例 #4
0
class ScenarioComparisonOperatorParameterTest(unittest.TestCase):
    """ Test OperatorParameter
    """
    def setUp(self):
        """ Create an Operator Parameter object
        """
        logging.basicConfig(format='%(levelname)s:%(message)s',
                            level=logging.DEBUG)
        self._obj = ComparisonOperatorParameter(log=logging)
        self._triggered = False

    def tearDown(self):
        """ Destroy cron object
        """
        del self._obj
        self._triggered = False

    def test_get_expected_entries(self):
        entries = self._obj.get_expected_entries()
        assert entries == {
            'operator': {
                'default': None,
                'values':
                ['<', '>', '==', '!=', '<=', '>=', 'is', 'in', 'not in'],
                'type': 'string',
                'description': 'Operator to use for comparison',
                'filters': {}
            }
        }

    def test_get_list_of_values(self):
        assert self._obj.get_list_of_values('operator') == [
            '<', '>', '==', '!=', '<=', '>=', 'is', 'in', 'not in'
        ]

    def test_evaluate_with_operator(self):
        for op in ['<', '>', '==', '!=', '<=', '>=', 'is', 'in', 'not in']:
            operator = {"operator": op}
            self._obj.fill(operator)
            assert self._obj.evaluate() == op

    def test_evaluate_with_no_operator(self):
        assert self._obj.evaluate() is None

    def test_fill_with_bad_operator(self):
        try:
            self._obj.fill({'operator': "bad"})
        except:
            pass
        else:
            TestCase.fail(
                self,
                "Operator 'bad' doesn't exist, exception should be raised")
コード例 #5
0
class ScenarioComparisonOperatorParameterTest(unittest.TestCase):
    """ Test OperatorParameter
    """

    def setUp(self):
        """ Create an Operator Parameter object
        """
        logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
        self._obj = ComparisonOperatorParameter(log=logging)
        self._triggered = False

    def tearDown(self):
        """ Destroy cron object
        """
        del self._obj
        self._triggered = False

    def test_get_expected_entries(self):
        entries = self._obj.get_expected_entries()
        assert entries == {'operator': {
            'default': None,
            'values': ['<', '>', '==', '!=', '<=', '>=', 'is', 'in', 'not in'],
            'type': 'string',
            'description': 'Operator to use for comparison',
            'filters': {}}}

    def test_get_list_of_values(self):
        assert self._obj.get_list_of_values('operator') == ['<', '>', '==', '!=', '<=', '>=', 'is', 'in', 'not in']

    def test_evaluate_with_operator(self):
        for op in ['<', '>', '==', '!=', '<=', '>=', 'is', 'in', 'not in']:
            operator = {"operator": op}
            self._obj.fill(operator)
            assert self._obj.evaluate() == op

    def test_evaluate_with_no_operator(self):
        assert self._obj.evaluate() is None

    def test_fill_with_bad_operator(self):
        try:
            self._obj.fill({'operator': "bad"})
        except:
            pass
        else:
            TestCase.fail(self, "Operator 'bad' doesn't exist, exception should be raised")
コード例 #6
0
 def setUp(self):
     """ Create a Cron Parameter object
     """
     logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
     self._obj = ComparisonOperatorParameter(log=logging)
     self._triggered = False