Exemplo n.º 1
0
    def test_max_values_incompatible(self):
        # Given
        args = (1, 'abc')

        # When
        with self.assertRaises(Exception) as exception:
            max_value(*args)

        # Then
        self.assertIn(
            "Cannot determine maximum of incompatible types max(<class 'int'>,"
            " <class 'str'>)", str(exception.exception))
Exemplo n.º 2
0
    def test_max_value_undefined(self):
        # Given
        args = ('foo', Undefined())

        # When
        with self.assertRaises(Exception) as exception:
            max_value(*args)

        # Then
        self.assertIn(
            "Cannot determine maximum of incompatible types max(<class 'str'>,"
            " <class 'jinja2.runtime.Undefined'>)", str(exception.exception))
Exemplo n.º 3
0
    def test_max_value_str(self):
        # Given
        two_str = ('a', 'abc')

        # When
        max_of_two = max_value(*two_str)

        # Then
        self.assertEqual(max_of_two, 'abc')
Exemplo n.º 4
0
    def test_max_values_compatible(self):
        # Given
        args = (-1, True)

        # When
        max_of_two = max_value(*args)

        # Then
        self.assertEqual(max_of_two, True)
Exemplo n.º 5
0
    def test_max_value_none(self):
        # Given
        one_int = (1, None)

        # When
        max_of_two = max_value(*one_int)

        # Then
        self.assertEqual(max_of_two, 1)
Exemplo n.º 6
0
    def test_max_value(self):
        # Given
        two_ints = (1, 2)

        # When
        max_of_two = max_value(*two_ints)

        # Then
        self.assertEqual(max_of_two, 2)
Exemplo n.º 7
0
    def test_max_value_date(self):
        # Given
        now = datetime.utcnow()
        then = now - timedelta(seconds=60)
        two_dates = (then, now)

        # When
        max_of_two = max_value(*two_dates)

        # Then
        self.assertEqual(max_of_two, now)