Skip to content
This repository has been archived by the owner on Jun 6, 2020. It is now read-only.

Commit

Permalink
Renamed ContentMod to ContentFilter to keep it consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewebdev committed Apr 20, 2016
1 parent e8f5a9c commit 933a808
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion demo/demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

'ostinato',
'ostinato.pages',
# 'ostinato.contentfilters',
'ostinato.contentfilters',

# Other dependencies
'mptt',
Expand Down
2 changes: 1 addition & 1 deletion ostinato/contentfilters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from templatetags.content_filters import ContentMod
from templatetags.content_filters import ContentFilter

13 changes: 7 additions & 6 deletions ostinato/contentfilters/templatetags/content_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
register = template.Library()


## ContentModifiers and related examples
class ContentMod(object):
# ContentModifiers and related examples
class ContentFilter(object):
"""
Special class to register render functions that will manipulate
text content in some way. These functions are accessed by the
Expand Down Expand Up @@ -57,7 +57,7 @@ def modify(content, mods=None):
{{ content|modify:"!snip,youtube" }}
"""
cm = ContentMod()
cm = ContentFilter()
if mods:
if mods[0] == "!":
# Exclusion List
Expand Down Expand Up @@ -106,6 +106,7 @@ def hide_snip(content):
return content.replace('{{{snip}}}', '')


ContentMod.register('youtube', youtube)
ContentMod.register('snip', snip)
ContentMod.register('hide_snip', hide_snip)
ContentFilter.register('youtube', youtube)
ContentFilter.register('snip', snip)
ContentFilter.register('hide_snip', hide_snip)

1 change: 0 additions & 1 deletion ostinato/contentfilters/views.py

This file was deleted.

Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.test import TestCase

from ostinato.contentfilters import ContentMod
from ostinato.contentfilters import ContentFilter
from ostinato.contentfilters.templatetags.content_filters import modify


Expand All @@ -21,47 +21,47 @@ class ContentModTestCase(TestCase):
""" Tests for the Content Modifier Class """

def clear_mods(self):
ContentMod._modifiers = []
ContentFilter._modifiers = []

def add_test_func(self):
ContentMod.register('test_func', test_func)
ContentMod.register('test_func_2', test_func_2)
ContentMod.register('test_func_3', test_func_3)
ContentFilter.register('test_func', test_func)
ContentFilter.register('test_func_2', test_func_2)
ContentFilter.register('test_func_3', test_func_3)

def test_class_exists(self):
ContentMod
ContentFilter

def test_register_class_method(self):
self.clear_mods()
self.assertEqual([], ContentMod._modifiers)
self.assertEqual([], ContentFilter._modifiers)

self.add_test_func()
self.assertEqual([
{'func': test_func, 'name': 'test_func'},
{'func': test_func_2, 'name': 'test_func_2'},
{'func': test_func_3, 'name': 'test_func_3'},
], ContentMod._modifiers)
], ContentFilter._modifiers)

def test_modifier(self):
self.clear_mods()
self.add_test_func()

cm = ContentMod()
cm = ContentFilter()
self.assertEqual([test_func, test_func_2, test_func_3], cm.modifiers())

def test_modifiers_exclude_list(self):
self.clear_mods()
self.add_test_func()

cm = ContentMod()
cm = ContentFilter()
self.assertEqual([test_func_2, test_func_3],
cm.modifiers(exclude='test_func'))

def test_getitem(self):
self.clear_mods()
self.add_test_func()

cm = ContentMod()
cm = ContentFilter()
self.assertEqual(test_func_2, cm['test_func_2'])

def test_modify_function_exists(self):
Expand Down
6 changes: 2 additions & 4 deletions ostinato/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@

'ostinato',

# Pages
'ostinato.tests.pages',
'ostinato.pages',

# Tests for the blog
'ostinato.tests.blog',

# 'ostinato.contentfilters',
'ostinato.contentfilters',
# 'ostinato.statemachine',

# Other dependencies
Expand Down
1 change: 1 addition & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'ostinato.tests.pages',
'ostinato.tests.statemachine',
'ostinato.tests.blog',
'ostinato.tests.contentfilters',
])

sys.exit(bool(failures))
Expand Down

0 comments on commit 933a808

Please sign in to comment.