def test_cache_list(self): ''' Test if it lists the NPM cache. ''' mock = MagicMock(return_value={'retcode': 1, 'stderr': 'error'}) with patch.dict(npm.__salt__, {'cmd.run_all': mock}): self.assertRaises(CommandExecutionError, npm.cache_list) mock = MagicMock(return_value={'retcode': 0, 'stderr': 'error', 'stdout': ['~/.npm']}) with patch.dict(npm.__salt__, {'cmd.run_all': mock}): self.assertEqual(npm.cache_list(), ['~/.npm']) mock = MagicMock(return_value={'retcode': 0, 'stderr': 'error', 'stdout': ''}) with patch.dict(npm.__salt__, {'cmd.run_all': mock}): self.assertEqual(npm.cache_list('coffee-script'), '')
def test_cache_list(self): """ Test if it lists the NPM cache. """ mock = MagicMock(return_value={"retcode": 1, "stderr": "error"}) with patch.dict(npm.__salt__, {"cmd.run_all": mock}): self.assertRaises(CommandExecutionError, npm.cache_list) mock = MagicMock( return_value={"retcode": 0, "stderr": "error", "stdout": ["~/.npm"]} ) with patch.dict(npm.__salt__, {"cmd.run_all": mock}): self.assertEqual(npm.cache_list(), ["~/.npm"]) mock = MagicMock(return_value={"retcode": 0, "stderr": "error", "stdout": ""}) with patch.dict(npm.__salt__, {"cmd.run_all": mock}): self.assertEqual(npm.cache_list("coffee-script"), "")