Skip to content

Commit

Permalink
100% test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Sep 9, 2017
1 parent c823c94 commit 5d99a99
Showing 1 changed file with 75 additions and 3 deletions.
78 changes: 75 additions & 3 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,16 @@ def test_svnlog(svncheckout):
assert stdout.startswith('<?xml')


def make_svninfo(url):
def make_svninfo(url, expected_path='.'):
def _svninfo(path):
assert path == expected_path
return textwrap.dedent('''\
Path: .
Path: %s
URL: %s
Repository UUID: ab69c8a2-bfcb-0310-9bff-acb20127a769
Revision: 1654
Node Kind: directory
''') % url
''') % (path, url)
return _svninfo


Expand Down Expand Up @@ -438,6 +439,19 @@ def test_ezmerge_diff():
]


def test_ezmerge_with_wc_path():
url = 'http://dev.worldcookery.com/svn/bla/trunk'
with mock.patch('eazysvn.svninfo', make_svninfo(url, '~/src/cookery')), \
mock.patch('eazysvn.svnlog', make_svnlog()), \
mock.patch('os.system') as mock_system:
es.ezmerge(['ezmerge', 'ALL', 'fix-bug-1234', '~/src/cookery'])
assert mock_system.mock_calls == [
mock.call('svn log -r 4505:4515 http://dev.worldcookery.com/svn/bla/branches/fix-bug-1234'),
mock.call('svn merge -r 4504:4515 http://dev.worldcookery.com/svn/bla/branches/fix-bug-1234 ~/src/cookery'),
]



def test_ezrevert():
url = 'http://dev.worldcookery.com/svn/bla/trunk'
with mock.patch('eazysvn.svninfo', make_svninfo(url)), \
Expand Down Expand Up @@ -479,6 +493,17 @@ def test_ezrevert_range():
]


def test_ezrevert_with_wc_path():
url = 'http://dev.worldcookery.com/svn/bla/trunk'
with mock.patch('eazysvn.svninfo', make_svninfo(url)), \
mock.patch('os.system') as mock_system:
es.ezrevert(['ezrevert', '5543', '~/src/cookery'])
assert mock_system.mock_calls == [
mock.call('svn log -r 5543:5543 ~/src/cookery'),
mock.call('svn merge -r 5543:5542 ~/src/cookery'),
]


def test_ezswitch():
url = 'http://dev.worldcookery.com/svn/bla/trunk'
with mock.patch('eazysvn.svninfo', make_svninfo(url)), \
Expand Down Expand Up @@ -547,6 +572,18 @@ def test_ezswitch_tag():
]


def test_ezswitch_with_wc_path():
url = 'http://dev.worldcookery.com/svn/bla/trunk'
with mock.patch('eazysvn.svninfo', make_svninfo(url, '~/src/cookery')), \
mock.patch('eazysvn.svnlog', make_svnlog()), \
mock.patch('os.system') as mock_system:
es.ezswitch(['ezswitch', 'fix-bug-1234', '~/src/cookery'])
assert mock_system.mock_calls == [
mock.call('svn switch http://dev.worldcookery.com/svn/bla/branches/fix-bug-1234 ~/src/cookery'),
]



def test_eztag():
url = 'http://dev.worldcookery.com/svn/bla/trunk'
with mock.patch('eazysvn.svninfo', make_svninfo(url)), \
Expand Down Expand Up @@ -593,6 +630,17 @@ def test_ezbranch_with_tag_name(capsys):
assert out == "http://dev.worldcookery.com/svn/bla/tags/v1.0\n"


def test_ezbranch_with_wc_path(capsys):
url = 'http://dev.worldcookery.com/svn/bla/branches/froggy'
with mock.patch('eazysvn.svninfo', make_svninfo(url, '~/src/cookery')), \
mock.patch('eazysvn.svnlog', make_svnlog()), \
mock.patch('os.system') as mock_system:
es.ezbranch(['ezbranch', 'trunk', '~/src/cookery'])
assert mock_system.mock_calls == []
out, err = capsys.readouterr()
assert out == "http://dev.worldcookery.com/svn/bla/trunk\n"


def test_rmbranch():
url = 'http://dev.worldcookery.com/svn/bla/trunk'
with mock.patch('eazysvn.svninfo', make_svninfo(url)), \
Expand Down Expand Up @@ -647,6 +695,20 @@ def test_branchdiff_with_explicit_branch_name():
]


def test_branchdiff_with_wc_path():
url = 'http://dev.worldcookery.com/svn/bla/trunk'
with mock.patch('eazysvn.svninfo', make_svninfo(url, '~/src/cookery')), \
mock.patch('eazysvn.svnlog', make_svnlog()), \
mock.patch('os.system') as mock_system:
es.eazysvn(['eazysvn', 'branchdiff', 'fix-bug-42', '~/src/cookery'])
assert mock_system.mock_calls == [
mock.call(
"svn diff -r 4504:4515"
" http://dev.worldcookery.com/svn/bla/branches/fix-bug-42"
),
]


def test_branchpoint(capsys):
url = 'http://dev.worldcookery.com/svn/bla/branches/fix-bug-42'
with mock.patch('eazysvn.svninfo', make_svninfo(url)), \
Expand All @@ -667,5 +729,15 @@ def test_branchpoint_with_explicit_branch_name(capsys):
assert out == "4504\n"


def test_branchpoint_with_wc_path(capsys):
url = 'http://dev.worldcookery.com/svn/bla/trunk'
with mock.patch('eazysvn.svninfo', make_svninfo(url, '~/src/cookery')), \
mock.patch('eazysvn.svnlog', make_svnlog()), \
mock.patch('os.system'):
es.eazysvn(['eazysvn', 'branchpoint', 'fix-bug-42', '~/src/cookery'])
out, err = capsys.readouterr()
assert out == "4504\n"


def test_additional_tests():
assert es.additional_tests().countTestCases() > 0

0 comments on commit 5d99a99

Please sign in to comment.