# Path: crudbuilder/helpers.py
# def plural(text):
# def mixedToUnder(s):  # pragma: no cover
# def mixedToUnderSub(match):
# def capword(s):
# def lowerword(s):  # pragma: no cover
# def underToMixed(name):
# def model_class_form(name):
# def underToAllCaps(value):  # pragma: no cover
# def import_crud(app):
# def auto_discover():
# def custom_postfix_url(crud, model):
# def get_urlresolver():
# 
# Path: crudbuilder/tests/models.py
# class TestModel(models.Model):
# 
#     name = models.CharField(blank=True, null=True, max_length=100)
#     email = models.EmailField(blank=True, null=True)
#     created_at = models.DateTimeField(auto_now=True)
# 
# Path: crudbuilder/tests/crud.py
# class TestModelCrud(BaseCrudBuilder):
#     model = TestModel
#     search_fields = ['name']
#     tables2_fields = ('name', 'email')
#     tables2_css_class = "table table-bordered table-condensed"
#     tables2_pagination = 20  # default is 10
#     modelform_excludes = ['created_by']
# 
# class TestChildInlineFormset(BaseInlineFormset):
#     inline_model = TestChildModel
#     parent_model = TestModel
#     exclude = ['created_by', 'updated_by']
# 
# Path: crudbuilder/tests/forms.py
# class TestModelForm(forms.ModelForm):
#     class Meta:
#         model = TestModel
#         fields = '__all__'
# 
#     def __init__(self, *args, **kwargs):
#         self.request = kwargs.pop('request', None)
#         # print(self.request.user)
#         super(TestModelForm, self).__init__(*args, **kwargs)
# 
# Path: crudbuilder/tests/tables.py
# class TestModelTable(tables.Table):
# 
#     class Meta:
#         model = TestModel
#         attrs = {"class": "table table-bordered table-condensed"}


from django.test import TestCase, Client
from django.contrib.auth.models import User
from django.template import Context, Template
from django.test.utils import override_settings
from crudbuilder.helpers import reverse
from crudbuilder.tests.models import TestModel
from crudbuilder.tests.crud import TestModelCrud, TestChildInlineFormset
from crudbuilder.tests.forms import TestModelForm
from crudbuilder.tests.tables import TestModelTable
        self.assertEqual(response.status_code, 302)
        self.assertEqual(TestModel.objects.count(), 1)

        response = self.client.post('/crud/tests/testmodels/1/update/', data)
        self.assertEqual(response.status_code, 302)

    @override_settings(PERMISSION_REQUIRED_FOR_CRUD=True)
    def test_permission_required_enabled(self):
        self.client_login()
        response = self.client.get('/crud/tests/testmodels/')
        self.assertEqual(302, response.status_code)

    def test_search_list(self):
        self.client_login()
        response = self.client.get('/crud/tests/testmodels/?search=some_text')
        self.assertEqual(200, response.status_code)

    @override_settings(LOGIN_REQUIRED_FOR_CRUD=False)
    def test_no_login(self):
        response = self.client.get(reverse('tests-testmodels-list'))
        self.assertEqual(200, response.status_code)

    def test_separate_createupdateform(self):
        TestModelCrud.custom_modelform = None
        TestModelCrud.createupdate_forms = dict(
            create=TestModelForm,
            update=TestModelForm)

        self.client_login()
        data = {'name': 'Test text', 'email': 'sa@me.org'}

# Path: crudbuilder/helpers.py
# def plural(text):
# def mixedToUnder(s):  # pragma: no cover
# def mixedToUnderSub(match):
# def capword(s):
# def lowerword(s):  # pragma: no cover
# def underToMixed(name):
# def model_class_form(name):
# def underToAllCaps(value):  # pragma: no cover
# def import_crud(app):
# def auto_discover():
# def custom_postfix_url(crud, model):
# def get_urlresolver():
# 
# Path: crudbuilder/tests/models.py
# class TestModel(models.Model):
# 
#     name = models.CharField(blank=True, null=True, max_length=100)
#     email = models.EmailField(blank=True, null=True)
#     created_at = models.DateTimeField(auto_now=True)
# 
# Path: crudbuilder/tests/crud.py
# class TestModelCrud(BaseCrudBuilder):
#     model = TestModel
#     search_fields = ['name']
#     tables2_fields = ('name', 'email')
#     tables2_css_class = "table table-bordered table-condensed"
#     tables2_pagination = 20  # default is 10
#     modelform_excludes = ['created_by']
# 
# class TestChildInlineFormset(BaseInlineFormset):
#     inline_model = TestChildModel
#     parent_model = TestModel
#     exclude = ['created_by', 'updated_by']
# 
# Path: crudbuilder/tests/forms.py
# class TestModelForm(forms.ModelForm):
#     class Meta:
#         model = TestModel
#         fields = '__all__'
# 
#     def __init__(self, *args, **kwargs):
#         self.request = kwargs.pop('request', None)
#         # print(self.request.user)
#         super(TestModelForm, self).__init__(*args, **kwargs)
# 
# Path: crudbuilder/tests/tables.py
# class TestModelTable(tables.Table):
# 
#     class Meta:
#         model = TestModel
#         attrs = {"class": "table table-bordered table-condensed"}


# Path: crudbuilder/tests/test_views.py
from django.test import TestCase, Client
from django.contrib.auth.models import User
from django.template import Context, Template
from django.test.utils import override_settings
from crudbuilder.helpers import reverse
from crudbuilder.tests.models import TestModel
from crudbuilder.tests.crud import TestModelCrud, TestChildInlineFormset
from crudbuilder.tests.forms import TestModelForm
from crudbuilder.tests.tables import TestModelTable

        self.assertEqual(response.status_code, 302)
        self.assertEqual(TestModel.objects.count(), 1)

        response = self.client.post('/crud/tests/testmodels/1/update/', data)
        self.assertEqual(response.status_code, 302)

    @override_settings(PERMISSION_REQUIRED_FOR_CRUD=True)
    def test_permission_required_enabled(self):
        self.client_login()
        response = self.client.get('/crud/tests/testmodels/')
        self.assertEqual(302, response.status_code)

    def test_search_list(self):
        self.client_login()
        response = self.client.get('/crud/tests/testmodels/?search=some_text')
        self.assertEqual(200, response.status_code)

    @override_settings(LOGIN_REQUIRED_FOR_CRUD=False)
    def test_no_login(self):
        response = self.client.get(reverse('tests-testmodels-list'))
        self.assertEqual(200, response.status_code)

    def test_separate_createupdateform(self):
        TestModelCrud.custom_modelform = None
        TestModelCrud.createupdate_forms = dict(
            create=TestModelForm,
            update=TestModelForm)

        self.client_login()
        data = {'name': 'Test text', 'email': 'sa@me.org'}

        self.assertEqual(TestModel.objects.count(), 0)