def test_cache_path(self): ''' Test if it prints the NPM cache path. ''' mock = MagicMock(return_value={'retcode': 1, 'stderr': 'error'}) with patch.dict(npm.__salt__, {'cmd.run_all': mock}): self.assertEqual(npm.cache_path(), 'error') mock = MagicMock(return_value={'retcode': 0, 'stderr': 'error', 'stdout': '/User/salt/.npm'}) with patch.dict(npm.__salt__, {'cmd.run_all': mock}): self.assertEqual(npm.cache_path(), '/User/salt/.npm')
def test_cache_path(self): """ Test if it prints the NPM cache path. """ mock = MagicMock(return_value={"retcode": 1, "stderr": "error"}) with patch.dict(npm.__salt__, {"cmd.run_all": mock}): self.assertEqual(npm.cache_path(), "error") mock = MagicMock( return_value={"retcode": 0, "stderr": "error", "stdout": "/User/salt/.npm"} ) with patch.dict(npm.__salt__, {"cmd.run_all": mock}): self.assertEqual(npm.cache_path(), "/User/salt/.npm")