Permalink
Browse files

Brew unit tests done for now

  • Loading branch information...
rallytime committed Mar 6, 2014
1 parent f5f089b commit b2b05f0e9d0e92dab1e0d4551d6c83c328e6c97c
Showing with 28 additions and 0 deletions.
  1. +28 −0 tests/unit/modules/brew_test.py
@@ -106,6 +106,21 @@ def test_version(self):
# 'latest_version' function tests: 0
# It has not been fully implemented
+ # 'remove' function tests: 1
+ # Only tested a few basics
+ # Full functionality should be tested in integration phase
+
+ @patch('salt.modules.brew.list_pkgs',
+ MagicMock(return_value={'test': '0.1.5'}))
+ def test_remove(self):
+ '''
+ Tests if package to be removed exists
+ '''
+ mock_params = MagicMock(return_value=({'foo': None}, 'repository'))
+ with patch.dict(brew.__salt__,
+ {'pkg_resource.parse_targets': mock_params}):
+ self.assertEqual(brew.remove('foo'), {})
+
# 'refresh_db' function tests: 2
@patch('salt.modules.brew._homebrew_bin',
@@ -132,6 +147,19 @@ def test_refresh_db(self):
'cmd.retcode': mock_success}):
self.assertTrue(brew.refresh_db())
+ # 'install' function tests: 1
+ # Only tested a few basics
+ # Full functionality should be tested in integration phase
+
+ def test_install(self):
+ '''
+ Tests if package to be installed exists
+ '''
+ mock_params = MagicMock(return_value=[None, None])
+ with patch.dict(brew.__salt__,
+ {'pkg_resource.parse_targets': mock_params}):
+ self.assertEqual(brew.install('name=foo'), {})
+
if __name__ == '__main__':
from integration import run_tests

0 comments on commit b2b05f0

Please sign in to comment.