commit 1b65342dffffa3cadc3f1cf62a549c5b565c1c9e Author: Damian Johnson atagar@torproject.org Date: Fri Apr 1 10:47:15 2016 -0700
Merge expand_path.py test into init
This only had a single test for an __init__.py util. Good start for a module that tests all util fuctions there. --- test/__init__.py | 22 ++++++++++++++++++++++ test/expand_path.py | 21 --------------------- 2 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/test/__init__.py b/test/__init__.py index 99ed76f..05acdaa 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -2,6 +2,12 @@ Unit tests for nyx. """
+import unittest + +from nyx import expand_path, uses_settings + +from mock import patch, Mock + __all__ = [ 'arguments', 'expand_path', @@ -9,3 +15,19 @@ __all__ = [ 'log', 'tracker', ] + + +class TestBaseUtil(unittest.TestCase): + @patch('nyx.tor_controller') + @patch('stem.util.system.cwd', Mock(return_value = '/your_cwd')) + @uses_settings + def test_expand_path(self, tor_controller_mock, config): + tor_controller_mock().get_pid.return_value = 12345 + self.assertEqual('/absolute/path/to/torrc', expand_path('/absolute/path/to/torrc')) + self.assertEqual('/your_cwd/torrc', expand_path('torrc')) + + config.set('tor.chroot', '/chroot') + self.assertEqual('/chroot/absolute/path/to/torrc', expand_path('/absolute/path/to/torrc')) + self.assertEqual('/chroot/your_cwd/torrc', expand_path('torrc')) + + config.set('tor.chroot', None) diff --git a/test/expand_path.py b/test/expand_path.py deleted file mode 100644 index 559712a..0000000 --- a/test/expand_path.py +++ /dev/null @@ -1,21 +0,0 @@ -import unittest - -from nyx import expand_path, uses_settings - -from mock import patch, Mock - - -class TestExpandPath(unittest.TestCase): - @patch('nyx.tor_controller') - @patch('stem.util.system.cwd', Mock(return_value = '/your_cwd')) - @uses_settings - def test_expand_path(self, tor_controller_mock, config): - tor_controller_mock().get_pid.return_value = 12345 - self.assertEqual('/absolute/path/to/torrc', expand_path('/absolute/path/to/torrc')) - self.assertEqual('/your_cwd/torrc', expand_path('torrc')) - - config.set('tor.chroot', '/chroot') - self.assertEqual('/chroot/absolute/path/to/torrc', expand_path('/absolute/path/to/torrc')) - self.assertEqual('/chroot/your_cwd/torrc', expand_path('torrc')) - - config.set('tor.chroot', None)
tor-commits@lists.torproject.org