Mercurial > hgsubversion
changeset 139:89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Thu, 11 Dec 2008 20:24:48 -0600 |
parents | 40474f6c1f84 |
children | 9ffde8662967 |
files | tests/test_util.py tests/test_utility_commands.py |
diffstat | 2 files changed, 51 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_util.py +++ b/tests/test_util.py @@ -75,7 +75,7 @@ class MockUI(object): self.inner_ui = self.real_ui(parentui=parentui) def status(self, *args): - self.stream.write(*args) + self.stream.write(''.join(args)) def warn(self, *args): self.stream.write(*args)
new file mode 100644 --- /dev/null +++ b/tests/test_utility_commands.py @@ -0,0 +1,50 @@ +import urllib # for url quoting + +from mercurial import ui +from mercurial import hg + +import utility_commands + +import test_util + +expected_info_output = '''URL: file://%(repo)s/%(branch)s +Repository Root: None +Repository UUID: df2126f7-00ab-4d49-b42c-7e981dde0bcf +Revision: %(rev)s +Node Kind: directory +Last Changed Author: durin +Last Changed Rev: %(rev)s +Last Changed Date: %(date)s +''' + +class UtilityTests(test_util.TestBase): + def test_info_output(self): + self._load_fixture_and_fetch('two_heads.svndump') + hg.update(self.repo, 'the_branch') + u = ui.ui() + utility_commands.run_svn_info(u, self.repo, self.wc_path) + expected = (expected_info_output % + {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', + 'repo': urllib.quote(self.repo_path), + 'branch': 'branches/the_branch', + 'rev': 5, + }) + self.assertEqual(u.stream.getvalue(), expected) + hg.update(self.repo, 'default') + u = ui.ui() + utility_commands.run_svn_info(u, self.repo, self.wc_path) + expected = (expected_info_output % + {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', + 'repo': urllib.quote(self.repo_path), + 'branch': 'trunk', + 'rev': 6, + }) + self.assertEqual(u.stream.getvalue(), expected) + + def test_url_output(self): + self._load_fixture_and_fetch('two_revs.svndump') + hg.update(self.repo, 'tip') + u = ui.ui() + utility_commands.print_wc_url(u, self.repo, self.wc_path) + expected = 'file://%s\n' % urllib.quote(self.repo_path) + self.assertEqual(u.stream.getvalue(), expected)