Beispiel #1
0
class ConditionValueIntegerFieldTests(TestCase):
    """Unit tests for djblets.conditions.values.ConditionValueIntegerField."""
    def setUp(self):
        super(ConditionValueIntegerFieldTests, self).setUp()

        self.value_field = ConditionValueIntegerField()

    def test_deserialize_value(self):
        """Testing ConditionValueIntegerField.deserialize_value"""
        self.assertEqual(self.value_field.deserialize_value(100), 100)
        self.assertEqual(self.value_field.deserialize_value('100'), 100)
Beispiel #2
0
class ConditionValueIntegerFieldTests(TestCase):
    """Unit tests for djblets.conditions.values.ConditionValueIntegerField."""

    def setUp(self):
        super(ConditionValueIntegerFieldTests, self).setUp()

        self.value_field = ConditionValueIntegerField()

    def test_deserialize_value(self):
        """Testing ConditionValueIntegerField.deserialize_value"""
        self.assertEqual(self.value_field.deserialize_value(100), 100)
        self.assertEqual(self.value_field.deserialize_value('100'), 100)
Beispiel #3
0
    def test_with_overrides(self):
        """Testing BaseConditionOperator.with_overrides"""
        class MyOperator(BaseConditionOperator):
            operator_id = 'my-op'
            name = 'My Op'

            value_field = BaseConditionValueField()

        CustomOperator = MyOperator.with_overrides(
            name='Custom Op', value_field=ConditionValueIntegerField())

        self.assertEqual(CustomOperator.__name__, 'CustomMyOperator')
        self.assertEqual(CustomOperator.name, 'Custom Op')
        self.assertIs(CustomOperator.value_field.__class__,
                      ConditionValueIntegerField)
Beispiel #4
0
class BaseConditionIntegerChoice(BaseConditionChoice):
    """Base class for a standard integer-based condition choice.

    This is a convenience for choices that are based on integers. It provides
    some standard operators that work well with integers for checking.
    """

    operators = ConditionOperators([
        IsOperator,
        IsNotOperator,
        GreaterThanOperator,
        LessThanOperator,
    ])

    default_value_field = ConditionValueIntegerField()
Beispiel #5
0
    def setUp(self):
        super(ConditionValueIntegerFieldTests, self).setUp()

        self.value_field = ConditionValueIntegerField()
Beispiel #6
0
    def setUp(self):
        super(ConditionValueIntegerFieldTests, self).setUp()

        self.value_field = ConditionValueIntegerField()
 class MyOperator(BaseConditionOperator):
     operator_id = 'my-op'
     name = 'My Op'
     value_field = ConditionValueIntegerField()