def test_valid(self):
        dt = datetime.datetime(2016, 1, 1).replace(tzinfo=datetime.timezone.utc)

        self.assertEqual(
            cdms_datetime_to_datetime('/Date(1451606400000)/'),
            dt
        )
    def has_cdms_obj_changed(self, local_obj, cdms_data):
        cdms_modified_on = self.get_modified_on(cdms_data)
        cdms_created_on = cdms_datetime_to_datetime(cdms_data['CreatedOn'])

        change_delta = (cdms_modified_on - local_obj.modified).total_seconds()

        if change_delta < 0:
            raise ObjectsNotInSyncException(
                'Django Model changed without being syncronised to CDMS, this should not happen'
            )

        return change_delta, cdms_modified_on, cdms_created_on
 def get_modified_on(self, cdms_data):
     return cdms_datetime_to_datetime(cdms_data['ModifiedOn'])
 def test_None(self):
     self.assertEqual(cdms_datetime_to_datetime(None), None)
 def test_invalid(self):
     self.assertEqual(cdms_datetime_to_datetime('invalid'), None)