Skip to content

Commit

Permalink
[#2041] Move old munge tests to new_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed Nov 19, 2014
1 parent 1fe0c61 commit 2b920f0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 39 deletions.
46 changes: 45 additions & 1 deletion ckan/new_tests/lib/test_munge.py
@@ -1,6 +1,7 @@
from nose import tools as nose_tools

from ckan.lib.munge import munge_filename
from ckan.lib.munge import (munge_filename, munge_name,
munge_title_to_name, munge_tag)


class TestMungeFilename(object):
Expand All @@ -18,3 +19,46 @@ def test_munge_filename_with_hyphens_multiple_pass(self):
# Munge twice
second_munged_filename = munge_filename(first_munged_filename)
nose_tools.assert_equal(expected_filename, second_munged_filename)


class TestMungeName(object):

def test_munge_name(self):
def test_munge(title, expected_munge):
munge = munge_name(title)
nose_tools.assert_equal(munge, expected_munge)

test_munge('unchanged', 'unchanged')
test_munge('bad spaces', 'bad-spaces')
test_munge('s', 's_') # too short
test_munge('random:other%character&', 'random-othercharacter')
test_munge(u'u with umlaut \xfc', 'u-with-umlaut-u')


class TestMungeTitleToName(object):

def test_munge_title_to_name(self):
def test_munge(title, expected_munge):
munge = munge_title_to_name(title)
nose_tools.assert_equal(munge, expected_munge)

test_munge('unchanged', 'unchanged')
test_munge('some spaces here', 'some-spaces-here')
test_munge('s', 's_') # too short
test_munge('random:other%character&', 'random-othercharacter')
test_munge(u'u with umlaut \xfc', 'u-with-umlaut-u')
test_munge('reallylong' * 12, 'reallylong' * 9 + 'reall')
test_munge('reallylong' * 12 + ' - 2012', 'reallylong' * 9 + '-2012')


class TestMungeTag:

def test_munge_tag(self):
def test_munge(title, expected_munge):
munge = munge_tag(title)
nose_tools.assert_equal(munge, expected_munge)

test_munge('unchanged', 'unchanged')
test_munge('s', 's_') # too short
test_munge('some spaces here', 'some-spaces--here')
test_munge('random:other%character&', 'randomothercharacter')
38 changes: 0 additions & 38 deletions ckan/tests/lib/test_munge.py

This file was deleted.

0 comments on commit 2b920f0

Please sign in to comment.