예제 #1
0
    def test_shortcut_dict_representation(self):
        """If precision is the default value, to_dict should return a string"""
        date_str = "2013-11-17T01:03:05"
        d = DateTimeWithPrecision()
        d.precision = "second"
        d.value = date_str

        self.assertEqual(str, type(d.to_dict()))
        self.assertEqual(datetime, type(d.value))
        self.assertEqual(date_str, d.to_dict())

        d2 = cybox.test.round_trip(d, output=True)
        self.assertEqual(d.to_dict(), d2.to_dict())
    def test_shortcut_dict_representation(self):
        """If precision is the default value, to_dict should return a string"""
        date_str = "2013-11-17T01:03:05"
        d = DateTimeWithPrecision()
        d.precision = "second"
        d.value = date_str

        self.assertEqual(str, type(d.to_dict()))
        self.assertEqual(datetime, type(d.value))
        self.assertEqual(date_str, d.to_dict())

        d2 = cybox.test.round_trip(d, output=True)
        self.assertEqual(d.to_dict(), d2.to_dict())
    def test_construction(self):
        d = DateTimeWithPrecision()
        d.precision = "hour"
        d.value = datetime(2014, 2, 4, 8, 21, 33)

        self.assertEqual(self._full_dict, d.to_dict())
예제 #4
0
    def test_construction(self):
        d = DateTimeWithPrecision()
        d.precision = "hour"
        d.value = datetime(2014, 2, 4, 8, 21, 33)

        self.assertEqual(self._full_dict, d.to_dict())