Skip to content

Commit

Permalink
Actually fix tests
Browse files Browse the repository at this point in the history
Some where mistakenly passing because /etc/paasta exists on the dev boxes, but don't in real testing environments
  • Loading branch information
mtbentley committed Jun 9, 2016
1 parent 5055cce commit 9681012
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
19 changes: 15 additions & 4 deletions tests/test_chronos_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,17 @@ def test_load_chronos_config_good(self):
file_mock = mock.MagicMock(spec=file)
with contextlib.nested(
mock.patch('paasta_tools.utils.open', create=True, return_value=file_mock),
mock.patch('json.load', autospec=True, return_value=from_file)
mock.patch('json.load', autospec=True, return_value=from_file),
mock.patch('os.path.isdir', autospec=True, return_value=True),
mock.patch('os.access', autospec=True, return_value=True),
mock.patch('paasta_tools.utils.get_readable_files_in_glob', autospec=True,
return_value=['/some/fake/dir/some_file.json']),
) as (
open_file_patch,
json_patch
json_patch,
isdir_patch,
access_patch,
get_readable_files_patch,
):
assert chronos_tools.load_chronos_config() == expected
open_file_patch.assert_called()
Expand All @@ -134,10 +141,14 @@ def test_load_chronos_config_bad(self):
file_mock = mock.MagicMock(spec=file)
with contextlib.nested(
mock.patch('paasta_tools.utils.open', create=True, return_value=file_mock),
mock.patch('json.load', autospec=True, return_value=from_file)
mock.patch('json.load', autospec=True, return_value=from_file),
mock.patch('os.path.isdir', autospec=True, return_value=True),
mock.patch('os.access', autospec=True, return_value=True),
) as (
open_patch,
json_patch
json_patch,
isdir_patch,
access_patch,
):
with raises(PaastaNotConfiguredError) as excinfo:
chronos_tools.load_chronos_config()
Expand Down
15 changes: 13 additions & 2 deletions tests/test_marathon_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,17 @@ def test_load_marathon_config(self):
file_mock = mock.MagicMock(spec=file)
with contextlib.nested(
mock.patch('paasta_tools.utils.open', create=True, return_value=file_mock),
mock.patch('json.load', autospec=True, return_value=from_file)
mock.patch('json.load', autospec=True, return_value=from_file),
mock.patch('os.path.isdir', autospec=True, return_value=True),
mock.patch('os.access', autospec=True, return_value=True),
mock.patch('paasta_tools.utils.get_readable_files_in_glob', autospec=True,
return_value=['/some/fake/dir/some_file.json']),
) as (
open_file_patch,
json_patch
json_patch,
isdir_patch,
access_patch,
get_readable_files_patch,
):
assert marathon_tools.load_marathon_config() == expected
open_file_patch.assert_called()
Expand All @@ -257,8 +264,12 @@ def test_load_marathon_config(self):
def test_load_marathon_config_path_dne(self):
with contextlib.nested(
mock.patch('paasta_tools.marathon_tools.open', create=True, side_effect=IOError(2, 'a', 'b')),
mock.patch('os.path.isdir', autospec=True, return_value=True),
mock.patch('os.access', autospec=True, return_value=True),
) as (
open_patch,
isdir_patch,
access_patch,
):
with raises(marathon_tools.PaastaNotConfiguredError) as excinfo:
marathon_tools.load_marathon_config()
Expand Down

0 comments on commit 9681012

Please sign in to comment.