Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Oct 4, 2022
1 parent dda325b commit fe36d88
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions tests/unit/test_rose_stem_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
from metomi.rose.fs_util import FileSystemUtil


class MockPopen:
def __init__(self, mocked_return):
self.mocked_return = mocked_return

def run(self, *args):
return self.mocked_return


@pytest.mark.parametrize(
'args, expect',
[
Expand Down Expand Up @@ -133,11 +141,8 @@ def test__add_define_option(get_StemRunner, capsys, exisiting_defines):
)
def test__get_fcm_loc_layout_info(get_StemRunner, capsys, mocked_return):
"""It parses information from fcm loc layout"""
class MockPopen:
def run(*args):
return mocked_return

stemrunner = get_StemRunner({'popen': MockPopen()})
stemrunner = get_StemRunner({'popen': MockPopen(mocked_return)})

if mocked_return[0] == 0:
expect = {
Expand All @@ -149,3 +154,29 @@ def run(*args):
with pytest.raises(ProjectNotFoundException) as exc:
stemrunner._get_fcm_loc_layout_info('foo')
assert mocked_return[2] in str(exc.value)


@pytest.mark.parametrize(
'source_dict, expect',
[
param(
{
'root': 'svn://subversive',
'project': 'waltheof',
'url': 'Irrelevent, it\'s mocked away, but required.'
},
'waltheof',
id='all paths true'
)
]
)
def test__get_project_from_url(get_StemRunner, source_dict, expect):
mockreturn = (
0,
"location{primary}[mortimer] = svn://subversive/rogermortimer\n"
"location{primary}[fenwick] = svn://subversive/johnfenwick\n"
"location{primary}[waltheof] = svn://subversive/waltheof\n",
)
stemrunner = get_StemRunner({'popen': MockPopen(mockreturn)})
project = stemrunner._get_project_from_url(source_dict)
assert project == expect

0 comments on commit fe36d88

Please sign in to comment.