Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Mark code that cannot be tested as nocover, including obsolete code a…
Browse files Browse the repository at this point in the history
…nd migrations
  • Loading branch information
Wtower committed Apr 4, 2016
1 parent f078fa6 commit 5c518f3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
1 change: 0 additions & 1 deletion ninecms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from django import forms
from django.forms.models import inlineformset_factory
from django.contrib.admin.widgets import FilteredSelectMultiple
from django.contrib.auth.models import Group
from django.utils.translation import ugettext_lazy as _
from ninecms.models import Node, Image, File, Video, ContentBlock, PageType, TaxonomyTerm
Expand Down
17 changes: 12 additions & 5 deletions ninecms/migrations/0013_auto_20160117_1209.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-01-17 10:09

# Overridden migration to prepare default value for block name
# and to transfer elements to new m2m field

# Several lines excluded from tests with pragma nocover
# Haven't found a working way to test migrations, the following have been tested:
# https://micknelson.wordpress.com/2013/03/01/testing-django-migrations/
# https://www.caktusgroup.com/blog/2016/02/02/writing-unit-tests-django-migrations/
# Other migrations include 0009

from __future__ import unicode_literals
from django.db import migrations, models


def str_block(block):
def str_block(block): # pragma: nocover
""" Get title based on block type
The default `__str__` methods do not operate within migrations
:return: model title
Expand All @@ -23,28 +30,28 @@ def str_block(block):

# noinspection PyUnusedLocal
# noinspection PyPep8Naming
def provide_block_name_default(apps, schema_editor): # pragma: nocover
def provide_block_name_default(apps, schema_editor):
""" Provide a default block name in order for the next migration to establish field unique
:param apps
:param schema_editor
:return: None
"""
Block = apps.get_model('ninecms', 'ContentBlock')
for block in Block.objects.all():
for block in Block.objects.all(): # pragma: nocover
block.name = '%s-%d' % (str_block(block), block.pk)
block.save()


# noinspection PyUnusedLocal
# noinspection PyPep8Naming
def transfer_elements(apps, schema_editor): # pragma: nocover
def transfer_elements(apps, schema_editor):
""" Transfer records from deprecated PageLayoutElements to new page_types block field
:param apps
:param schema_editor
:return: None
"""
PageLayoutElement = apps.get_model('ninecms', 'PageLayoutElement')
for element in PageLayoutElement.objects.all():
for element in PageLayoutElement.objects.all(): # pragma: nocover
element.block.page_types.add(element.page_type)


Expand Down
2 changes: 1 addition & 1 deletion ninecms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def __str__(self):
""" Get model name
:return: model name
"""
return ' '.join((str(self.page_type), self.region))
return ' '.join((str(self.page_type), self.region)) # pragma: nocover

class Meta:
""" Model meta """
Expand Down
13 changes: 1 addition & 12 deletions ninecms/templatetags/ninecms_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from django import template
from django.template.defaultfilters import stringfilter
from django.conf import settings
from django.template import Context
from ninecms.utils.media import image_style as util_image
from ninecms.utils.transliterate import upper_no_intonation as util_upper
Expand All @@ -20,23 +19,13 @@
@register.filter
def image_style(image, style):
""" Return the url of different image style
:param url: An image url
:param image: An image url
:param style: Specify style to return image
:return: image url of specified style
"""
return util_image(image, style)


@register.filter
def library(name):
""" Check if a library is enabled in settings
Mutliple checks with | separator
:param name: the library name to check
:return: a boolean value
"""
return any(x in name.split('|') for x in settings.LIBRARIES)


class FieldsetNode(template.Node): # pragma: nocover
""" Fieldset renderer for 'fieldset' tag (see below) """
def __init__(self, nodelist, fieldset_name):
Expand Down

0 comments on commit 5c518f3

Please sign in to comment.