Skip to content

Commit

Permalink
Add unittests for new converter
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelb committed Jun 25, 2014
1 parent 19c6920 commit 671e05d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions ckan/new_tests/logic/test_converters.py
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
'''Unit tests for ckan/logic/converters.py.
'''
import unittest
import ckan.logic.converters as converters


class TestRemoveWhitespaceConverter(unittest.TestCase):
def test_leading_space(self):
string = ' http://example.com'
expected = 'http://example.com'
converted = converters.remove_whitespace(string, {})
self.assertEqual(expected, converted)

def test_trailing_space(self):
string = 'http://example.com '
expected = 'http://example.com'
converted = converters.remove_whitespace(string, {})
self.assertEqual(expected, converted)

def test_space_between(self):
string = 'http://example.com/space between url '
expected = 'http://example.com/space between url'
converted = converters.remove_whitespace(string, {})
self.assertEqual(expected, converted)

def test_not_a_string(self):
string = 12345
expected = 12345
converted = converters.remove_whitespace(string, {})
self.assertEqual(string, converted)

0 comments on commit 671e05d

Please sign in to comment.