Permalink
Browse files

100% branch coverage

  • Loading branch information...
1 parent 7b556b4 commit 81ffd787a6bc96b3033aa50d08d8a49d9ace7ba6 @WoLpH committed Feb 9, 2014
Showing with 44 additions and 10 deletions.
  1. +12 −0 tests/test_base_models.py
  2. +10 −0 tests/test_choices.py
  3. +5 −2 tests/test_commands.py
  4. +17 −8 tests/test_view_decorators.py
View
@@ -1,12 +1,15 @@
from django_utils import base_models
+
class SaveableClass(object):
def save(self):
pass
+
class SluggedClass(base_models.SlugMixin, SaveableClass):
pass
+
def test_slug_mixin():
instance = SluggedClass()
instance.slug = None
@@ -18,3 +21,12 @@ def test_slug_mixin():
instance.name = 'named'
instance.save()
+
+class ModelBaseTest(base_models.ModelBase):
+ pass
+
+
+class ModelBaseProxyTest(ModelBaseTest):
+ class Meta:
+ proxy = True
+
View
@@ -1,5 +1,15 @@
from django.db import models
from django_utils import choices
+from django.utils.translation import ugettext_lazy as _
+
+
+class TranslatedHuman(models.Model):
+ class Gender(choices.Choices):
+ Male = choices.Choice('m', _('Male'))
+ Female = choices.Choice('f', _('Female'))
+ Other = choices.Choice('o', _('Other'))
+
+ gender = models.CharField(max_length=1, choices=Gender.choices)
class Human(models.Model):
View
@@ -21,12 +21,15 @@ def test_admin_autogen_command():
command = commands.admin_autogen.Command()
command.handle()
+ command.handle('tests.test_app')
command.handle('django.contrib.auth')
command.handle('django.contrib.auth', 'user')
- commands.admin_autogen.LIST_FILTER_THRESHOLD = 25
- commands.admin_autogen.RAW_ID_THRESHOLD = 25
+ commands.admin_autogen.LIST_FILTER_THRESHOLD = 250
+ commands.admin_autogen.RAW_ID_THRESHOLD = 250
command.handle('tests.test_app')
+ command.handle('django.contrib.auth')
+ command.handle('django.contrib.auth', 'user')
sys.stderr = stderr
@@ -24,6 +24,22 @@ def is_ajax(self):
return self.ajax
+@view_decorators.env()
+def simple_view(request):
+ return ''
+
+
+@view_decorators.env(login_required=True)
+def simple_logged_in_view(request):
+ return ''
+
+
+def test_other_view():
+ request = Request(ajax=True)
+ simple_logged_in_view(request)
+ simple_view(request)
+
+
@view_decorators.env
def some_view(request, return_=None, jinja=False):
request.jinja = jinja
@@ -37,12 +53,7 @@ def some_view(request, return_=None, jinja=False):
return return_
-@view_decorators.env(login_required=True)
-def other_view(request):
- pass
-
-
-def test_view():
+def test_some_view():
some_view(Request(), return_='')
some_view(Request(ajax=True), return_='')
some_view(Request(ajax=True), return_={})
@@ -77,8 +88,6 @@ def test_view():
some_view(request, return_=http.HttpResponse())
some_view(request, jinja=True)
- other_view(request)
-
def test_import():
import __builtin__

0 comments on commit 81ffd78

Please sign in to comment.