예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
    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)
예제 #6
0
 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)
예제 #7
0
 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)
예제 #8
0
    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
        )