# Path: arangodb/orm/fields.py
# class DatetimeField(ModelField):
# 
#     DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
# 
#     def __init__(self, **kwargs):
#         """
#         """
# 
#         super(DatetimeField, self).__init__(**kwargs)
# 
#         if self.null and not self.default:
#             self.time = None
#         else:
#             if self.default:
#                 self.time = self.default
#             else:
#                 self.time = datetime.now()
# 
#     def dumps(self):
#         """
#         """
# 
#         if self.null and self.time is None:
#             return None
#         else:
#             if self.time is None:
#                 raise Exception('Datetime cannot be None')
#             else:
#                 return '%s' % self.time.strftime(DatetimeField.DATE_FORMAT)
# 
#     def loads(self, date_string):
#         """
#         """
# 
#         if not self.null:
#             self.time = datetime.strptime(date_string, DatetimeField.DATE_FORMAT)
#         else:
#             self.time = None
# 
#     def validate(self):
#         """
#         """
# 
#     def set(self, *args, **kwargs):
#         """
#         """
# 
#         if len(args) is 1:
#             time = args[0]
#             if isinstance(args, six.string_types):
#                 self.loads(time)
#             else:
#                 self.time = time
# 
#     def get(self):
#         """
#         """
# 
#         return self.time
# 
#     def __eq__(self, other):
#         """
#         """
# 
#         if super(DatetimeField, self).__eq__(other):
#             return self.time == other.time
#         else:
#             return False


import unittest
import datetime
from arangodb.orm.fields import DatetimeField



class DatetimeFieldTestCase(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_basic_creation_with_default(self):
        time = datetime.datetime.now()

# Path: arangodb/orm/fields.py
# class DatetimeField(ModelField):
# 
#     DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
# 
#     def __init__(self, **kwargs):
#         """
#         """
# 
#         super(DatetimeField, self).__init__(**kwargs)
# 
#         if self.null and not self.default:
#             self.time = None
#         else:
#             if self.default:
#                 self.time = self.default
#             else:
#                 self.time = datetime.now()
# 
#     def dumps(self):
#         """
#         """
# 
#         if self.null and self.time is None:
#             return None
#         else:
#             if self.time is None:
#                 raise Exception('Datetime cannot be None')
#             else:
#                 return '%s' % self.time.strftime(DatetimeField.DATE_FORMAT)
# 
#     def loads(self, date_string):
#         """
#         """
# 
#         if not self.null:
#             self.time = datetime.strptime(date_string, DatetimeField.DATE_FORMAT)
#         else:
#             self.time = None
# 
#     def validate(self):
#         """
#         """
# 
#     def set(self, *args, **kwargs):
#         """
#         """
# 
#         if len(args) is 1:
#             time = args[0]
#             if isinstance(args, six.string_types):
#                 self.loads(time)
#             else:
#                 self.time = time
# 
#     def get(self):
#         """
#         """
# 
#         return self.time
# 
#     def __eq__(self, other):
#         """
#         """
# 
#         if super(DatetimeField, self).__eq__(other):
#             return self.time == other.time
#         else:
#             return False


# Path: arangodb/tests/orm/fields/datetime_field.py
import unittest
import datetime
from arangodb.orm.fields import DatetimeField




class DatetimeFieldTestCase(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_basic_creation_with_default(self):
        time = datetime.datetime.now()

        field = DatetimeField(default=time)