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))
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))
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')
def test_max_values_compatible(self): # Given args = (-1, True) # When max_of_two = max_value(*args) # Then self.assertEqual(max_of_two, True)
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)
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)
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)