Skip to content
This repository has been archived by the owner on Feb 14, 2018. It is now read-only.

Commit

Permalink
Minor tinman.application cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin M. Roy committed Jun 30, 2012
1 parent 4855a3a commit daf303e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
12 changes: 2 additions & 10 deletions tests/application_test.py
Expand Up @@ -13,24 +13,16 @@
class ApplicationTests(unittest.TestCase):

def setUp(self):

self._mock_obj = mock.Mock(spec=application.TinmanApplication)


def test_load_translations(self):

with mock.patch('tornado.locale.load_translations') as mock_load:


path = '/foo'
print application.TinmanApplication._load_translations(self._mock_obj, path)
application.TinmanApplication._load_translations(self._mock_obj,
path)
mock_load.assert_called_once_with(path)






class AttributeTests(unittest.TestCase):

def test_add_attribute_exists(self):
Expand Down
23 changes: 9 additions & 14 deletions tinman/application.py
Expand Up @@ -120,26 +120,21 @@ def _prepare_paths(self):
def _replace_path(self, path_name, name, value):
"""Replace the name with the value for the given path_name name.
:param path_name: The path_name name
:type path_name: str
:param name: The string to replace in original string
:type name: str
:param value: The string value replacement value for name
:type value: str
:param str path_name: The path_name name
:param str name: The string to replace in original string
:param str value: The string value replacement value for name
"""
# If we have a base path_name, replace it if needed
if self._settings[path_name]:
if path_name in self._settings:
self._settings[path_name] = self._settings[path_name].replace(name,
value)

def _set_path(self, path_name, path_value):
"""Set the specified path setting with the given value
:param path_name: The path to set
:type path_name: str
:param path_value: Path to set it to
:type path_value: str
:param str path_name: The path to set
:param str path_value: Path to set it to
"""
self._settings[path_name] = path_value
Expand All @@ -148,9 +143,9 @@ def _prepare_route(self, attributes):
"""Take a given inbound list for a route and parse it creating the
route and importing the class it belongs to.
:param attributes: Route attributes
:type attributes: list or tuple
:rtype: list of prepared route
:param list attributes: Route attributes
:rtype: list
"""
# Validate it's a list or set
if type(attributes) not in (list, tuple):
Expand Down

0 comments on commit daf303e

Please sign in to comment.