Esempio n. 1
0
    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')
Esempio n. 2
0
    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")