Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mocks in win_disim tests #39460

Merged
merged 1 commit into from Feb 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 41 additions & 32 deletions tests/unit/states/win_dism_test.py
Expand Up @@ -95,11 +95,12 @@ def test_capability_installed_installed(self):
dism.__salt__, {'dism.installed_capabilities': mock_installed,
'dism.add_capability': mock_add}):

out = dism.capability_installed('Capa2', 'somewhere', True)
with patch.dict(dism.__opts__, {'test': False}):
out = dism.capability_installed('Capa2', 'somewhere', True)

mock_installed.assert_called_once_with()
assert not mock_add.called
self.assertEqual(out, expected)
mock_installed.assert_called_once_with()
assert not mock_add.called
self.assertEqual(out, expected)

def test_capability_removed(self):
'''
Expand Down Expand Up @@ -360,13 +361,14 @@ def test_package_installed(self):
'dism.add_package': mock_add,
'dism.package_info': mock_info}):
with patch.dict(dism.__opts__, {'test': False}):
with patch('os.path.exists'):

out = dism.package_installed('Pack2')
out = dism.package_installed('Pack2')

mock_installed.assert_called_with()
mock_add.assert_called_once_with(
'Pack2', False, False, None, False)
self.assertEqual(out, expected)
mock_installed.assert_called_with()
mock_add.assert_called_once_with(
'Pack2', False, False, None, False)
self.assertEqual(out, expected)

def test_package_installed_failure(self):
'''
Expand All @@ -390,13 +392,14 @@ def test_package_installed_failure(self):
'dism.add_package': mock_add,
'dism.package_info': mock_info}):
with patch.dict(dism.__opts__, {'test': False}):
with patch('os.path.exists'):

out = dism.package_installed('Pack2')
out = dism.package_installed('Pack2')

mock_installed.assert_called_with()
mock_add.assert_called_once_with(
'Pack2', False, False, None, False)
self.assertEqual(out, expected)
mock_installed.assert_called_with()
mock_add.assert_called_once_with(
'Pack2', False, False, None, False)
self.assertEqual(out, expected)

def test_package_installed_installed(self):
'''
Expand All @@ -418,12 +421,14 @@ def test_package_installed_installed(self):
dism.__salt__, {'dism.installed_packages': mock_installed,
'dism.add_package': mock_add,
'dism.package_info': mock_info}):
with patch.dict(dism.__opts__, {'test': False}):
with patch('os.path.exists'):

out = dism.package_installed('Pack2')
out = dism.package_installed('Pack2')

mock_installed.assert_called_once_with()
assert not mock_add.called
self.assertEqual(out, expected)
mock_installed.assert_called_once_with()
assert not mock_add.called
self.assertEqual(out, expected)

def test_package_removed(self):
'''
Expand All @@ -448,13 +453,14 @@ def test_package_removed(self):
'dism.remove_package': mock_remove,
'dism.package_info': mock_info}):
with patch.dict(dism.__opts__, {'test': False}):
with patch('os.path.exists'):

out = dism.package_removed('Pack2')
out = dism.package_removed('Pack2')

mock_removed.assert_called_with()
mock_remove.assert_called_once_with(
'Pack2', None, False)
self.assertEqual(out, expected)
mock_removed.assert_called_with()
mock_remove.assert_called_once_with(
'Pack2', None, False)
self.assertEqual(out, expected)

def test_package_removed_failure(self):
'''
Expand All @@ -478,13 +484,14 @@ def test_package_removed_failure(self):
'dism.remove_package': mock_remove,
'dism.package_info': mock_info}):
with patch.dict(dism.__opts__, {'test': False}):
with patch('os.path.exists'):

out = dism.package_removed('Pack2')
out = dism.package_removed('Pack2')

mock_removed.assert_called_with()
mock_remove.assert_called_once_with(
'Pack2', None, False)
self.assertEqual(out, expected)
mock_removed.assert_called_with()
mock_remove.assert_called_once_with(
'Pack2', None, False)
self.assertEqual(out, expected)

def test_package_removed_removed(self):
'''
Expand All @@ -507,11 +514,13 @@ def test_package_removed_removed(self):
'dism.remove_package': mock_remove,
'dism.package_info': mock_info}):

out = dism.package_removed('Pack2')
with patch.dict(dism.__opts__, {'test': False}):
with patch('os.path.exists'):
out = dism.package_removed('Pack2')

mock_removed.assert_called_once_with()
assert not mock_remove.called
self.assertEqual(out, expected)
mock_removed.assert_called_once_with()
assert not mock_remove.called
self.assertEqual(out, expected)


if __name__ == '__main__':
Expand Down