# Path: lighty/db/fields.py
# def add_validator(validator, options):
#     def __init__(self, verbose_name=None, primary_key=False, db_index=False,
#                        unique=False, blank=False, null=False, choices=None,
#                        default=None, editable=True, validators=(),
#                        help_text="", db_column=None, db_tablespace=False):
#     def configure(self, model_name, field_name):
#     def get_value_for_datastore(self, model):
#     def make_value_from_datastore(self, value):
#     def __str__(self, model=None):
#     def configure(self, model_name, field_name):
#     def __get__(self, instance, owner):
#     def __set__(self, instance, value):
#     def __init__(self, **options):
#     def __set__(self, instance, value):
#     def __init__(self, **options):
#     def __init__(self, **options):
#     def __set__(self, instance, value):
#     def __init__(self, max_digits=None, decimal_places=None, **options):
#     def __set__(self, instance, value):
#     def __init__(self, **options):
#     def __set__(self, instance, value):
#     def __init__(self, max_length=None, **options):
#     def __init__(self, max_length=75, **options):
#     def __init__(self, verify_exists=True, max_length=200, **options):
#     def __init__(self, **options):
#     def __init__(self, max_length=50, **options):
#     def __init__(self, auto_now=False, auto_now_add=False, **options):
#     def get_value_for_datastore(self, model):
#     def make_value_from_datastore(self, value):
#     def get_value_for_datastore(self, model):
#     def make_value_from_datastore(self, value):
#     def get_value_for_datastore(self, model):
#     def __init__(self, model, **kwargs):
#     def get_value_for_datastore(self, model):
#     def make_value_from_datastore(self, value):
# class Field(BaseField):
# class FieldDescriptor(Field):
# class IntegerField(FieldDescriptor, NumericField):
# class PositiveIntegerField(IntegerField):
# class AutoField(IntegerField):
# class FloatField(FieldDescriptor, NumericField):
# class DecimalField(Field, NumericField):
# class BooleanField(FieldDescriptor):
# class NullBooleanField(BooleanField):
# class CharField(Field, SequenceField):
# class EmailField(CharField):
# class URLField(CharField):
# class IPAddressField(Field):
# class SlugField(CharField):
# class DateField(Field, NumericField):
# class DateTimeField(DateField, NumericField):
# class TimeField(DateField, NumericField):
# class TextField(Field, SequenceField):
# class ForeignKey(Field):
# 
# Path: lighty/db/models.py
# def get_attr_source(name, cls):
#     def __new__(cls, name, bases, attrs):
#     def __init__(self, is_new=True, **kwds):
#     def datastore(cls):
#     def is_saved(self):
#     def key(self):
#     def put(self):
#     def delete(self):
#     def entity_name(cls):
#     def get(cls, _key=None, **keys):
#     def all(cls):
#     def fields(cls):
#     def validators(cls):
# class ModelBase(type):
# class Model(with_metaclass(ModelBase)):
# 
# Path: lighty/db/backend.py
# class Datastore(object):
# class DatastoreManager(object):
#     def __init__(self, name, db_name, **kwargs):
#     def get(self, model, kwargs):
#     def put(self, model, item):
#     def delete(self, model, **kwargs):
#     def get_datastore_operation(operation, operand=None):
#     def process_operand(operand):
#     def build_query(query):
#     def query(self, query, fields=None):
#     def count(self, query):
#     def slice(self, query, limit=1, offset=0):
#     def __init__(self, default_name='default'):
#     def connect(self, name, **kwargs):
#     def get(self, name=None):
#     def default(self):
#     def swap(self, first_name, second_name=None):


import unittest
from lighty.db import fields, models, backend
        from datetime import date, datetime, timedelta
'''Test case for MongoDB database backend
'''


backend.manager.connect('default')


class User(models.Model):
    name = fields.CharField()
    age = fields.IntegerField()
    created = fields.DateField(auto_now_add=True)
    changed = fields.DateTimeField(auto_now=True)
    birthday = fields.DateField(null=True)

    def __str__(self):
        return "%s %d" % (self.name, self.age)


def datetime_equals(first, second):
    return (first.year == second.year and first.month == second.month and
            first.day == second.day and first.hour == second.hour and
            first.minute == second.minute and first.second == second.second)


class MongoTestCase(unittest.TestCase):
    '''Test case for partial template execution
    '''
    def setUp(self):

# Path: lighty/db/fields.py
# def add_validator(validator, options):
#     def __init__(self, verbose_name=None, primary_key=False, db_index=False,
#                        unique=False, blank=False, null=False, choices=None,
#                        default=None, editable=True, validators=(),
#                        help_text="", db_column=None, db_tablespace=False):
#     def configure(self, model_name, field_name):
#     def get_value_for_datastore(self, model):
#     def make_value_from_datastore(self, value):
#     def __str__(self, model=None):
#     def configure(self, model_name, field_name):
#     def __get__(self, instance, owner):
#     def __set__(self, instance, value):
#     def __init__(self, **options):
#     def __set__(self, instance, value):
#     def __init__(self, **options):
#     def __init__(self, **options):
#     def __set__(self, instance, value):
#     def __init__(self, max_digits=None, decimal_places=None, **options):
#     def __set__(self, instance, value):
#     def __init__(self, **options):
#     def __set__(self, instance, value):
#     def __init__(self, max_length=None, **options):
#     def __init__(self, max_length=75, **options):
#     def __init__(self, verify_exists=True, max_length=200, **options):
#     def __init__(self, **options):
#     def __init__(self, max_length=50, **options):
#     def __init__(self, auto_now=False, auto_now_add=False, **options):
#     def get_value_for_datastore(self, model):
#     def make_value_from_datastore(self, value):
#     def get_value_for_datastore(self, model):
#     def make_value_from_datastore(self, value):
#     def get_value_for_datastore(self, model):
#     def __init__(self, model, **kwargs):
#     def get_value_for_datastore(self, model):
#     def make_value_from_datastore(self, value):
# class Field(BaseField):
# class FieldDescriptor(Field):
# class IntegerField(FieldDescriptor, NumericField):
# class PositiveIntegerField(IntegerField):
# class AutoField(IntegerField):
# class FloatField(FieldDescriptor, NumericField):
# class DecimalField(Field, NumericField):
# class BooleanField(FieldDescriptor):
# class NullBooleanField(BooleanField):
# class CharField(Field, SequenceField):
# class EmailField(CharField):
# class URLField(CharField):
# class IPAddressField(Field):
# class SlugField(CharField):
# class DateField(Field, NumericField):
# class DateTimeField(DateField, NumericField):
# class TimeField(DateField, NumericField):
# class TextField(Field, SequenceField):
# class ForeignKey(Field):
# 
# Path: lighty/db/models.py
# def get_attr_source(name, cls):
#     def __new__(cls, name, bases, attrs):
#     def __init__(self, is_new=True, **kwds):
#     def datastore(cls):
#     def is_saved(self):
#     def key(self):
#     def put(self):
#     def delete(self):
#     def entity_name(cls):
#     def get(cls, _key=None, **keys):
#     def all(cls):
#     def fields(cls):
#     def validators(cls):
# class ModelBase(type):
# class Model(with_metaclass(ModelBase)):
# 
# Path: lighty/db/backend.py
# class Datastore(object):
# class DatastoreManager(object):
#     def __init__(self, name, db_name, **kwargs):
#     def get(self, model, kwargs):
#     def put(self, model, item):
#     def delete(self, model, **kwargs):
#     def get_datastore_operation(operation, operand=None):
#     def process_operand(operand):
#     def build_query(query):
#     def query(self, query, fields=None):
#     def count(self, query):
#     def slice(self, query, limit=1, offset=0):
#     def __init__(self, default_name='default'):
#     def connect(self, name, **kwargs):
#     def get(self, name=None):
#     def default(self):
#     def swap(self, first_name, second_name=None):


# Path: tests/mongo.py
import unittest
from lighty.db import fields, models, backend
        from datetime import date, datetime, timedelta

'''Test case for MongoDB database backend
'''


backend.manager.connect('default')


class User(models.Model):
    name = fields.CharField()
    age = fields.IntegerField()
    created = fields.DateField(auto_now_add=True)
    changed = fields.DateTimeField(auto_now=True)
    birthday = fields.DateField(null=True)

    def __str__(self):
        return "%s %d" % (self.name, self.age)


def datetime_equals(first, second):
    return (first.year == second.year and first.month == second.month and
            first.day == second.day and first.hour == second.hour and
            first.minute == second.minute and first.second == second.second)


class MongoTestCase(unittest.TestCase):
    '''Test case for partial template execution
    '''
    def setUp(self):

        backend.manager.default.db.User.drop()