def test_bad_value(self): """ Test with values that are not supported. """ key = TimestampKey("test") with self.assertRaisesRegex(TankError, "Invalid type"): key.str_from_value(1)
def test_bad_value(self): """ Test with values that are not supported. """ key = TimestampKey("test") with self.assertRaisesRegex(TankError, "Invalid type"): key.str_from_value(1)
def test_string_default_value(self): """ Makes sure that a default value is proprely generated when a string default value is provided. """ # Create a template using our key. key = TimestampKey("datetime", default=self._datetime_string) # Convert to a string and compare the result. self.assertEqual(key.str_from_value(None), self._datetime_string)
def test_string_default_value(self): """ Makes sure that a default value is proprely generated when a string default value is provided. """ # Create a template using our key. key = TimestampKey("datetime", default=self._datetime_string) # Convert to a string and compare the result. self.assertEqual(key.str_from_value(None), self._datetime_string)
def test_str_from_value(self): """ Convert all supported value types into a string and validates that we are getting the right result """ key = TimestampKey("test") # Try and convert each and every date format to string self.assertEqual(key.str_from_value(self._datetime), self._datetime_string)
def test_utc_now_default_value(self, _get_utc_time_mock): """ Makes sure that a default value is proprely generated when the utc_now default value is requested. """ # Mock it to the expected date. _get_utc_time_mock.return_value = self._datetime # Create the key key = TimestampKey("datetime", default="utc_now") # Convert to a string and compare the result. self.assertEqual(key.str_from_value(None), self._datetime_string)
def test_utc_now_default_value(self, _get_utc_time_mock): """ Makes sure that a default value is proprely generated when the utc_now default value is requested. """ # Mock it to the expected date. _get_utc_time_mock.return_value = self._datetime # Create the key key = TimestampKey("datetime", default="utc_now") # Convert to a string and compare the result. self.assertEqual(key.str_from_value(None), self._datetime_string)
def test_str_from_value(self): """ Convert all supported value types into a string and validates that we are getting the right result """ key = TimestampKey("test") # Try and convert each and every date format to string self.assertEqual( key.str_from_value(self._datetime), self._datetime_string )