Ejemplo n.º 1
0
    def setUpClass(cls):
        super(TestConversion, cls).setUpClass()

        cls.db.put("times/3",
                   {"td": Utils.timedelta_to_str(timedelta(days=20, minutes=23, seconds=59, milliseconds=254)),
                    "dt": Utils.datetime_to_string(datetime.now())}, {"Raven-Entity-Name": "Times"})

        cls.db.put("times/4",
                   {"td": Utils.timedelta_to_str(timedelta(minutes=23, seconds=59, milliseconds=254)),
                    "dt": Utils.datetime_to_string(datetime.now())}, {"Raven-Entity-Name": "Times"})

        cls.document_store = documentstore(cls.default_url, cls.default_database)
        cls.document_store.initialize()
Ejemplo n.º 2
0
 def json_default(o):
     if isinstance(o, datetime):
         return Utils.datetime_to_string(o)
     elif isinstance(o, timedelta):
         return Utils.timedelta_to_str(o)
     elif getattr(o, "__dict__", None):
         return o.__dict__
     else:
         raise TypeError(repr(o) + " is not JSON serializable (Try add a json default method to store convention)")