Example #1
0
    def test_cache_clean(self):
        '''
        Test if it cleans the cached NPM packages.
        '''
        mock = MagicMock(return_value={'retcode': 1, 'stderr': 'error'})
        with patch.dict(npm.__salt__, {'cmd.run_all': mock}):
            self.assertFalse(npm.cache_clean())

        mock = MagicMock(return_value={'retcode': 0})
        with patch.dict(npm.__salt__, {'cmd.run_all': mock}):
            self.assertTrue(npm.cache_clean())

        mock = MagicMock(return_value={'retcode': 0})
        with patch.dict(npm.__salt__, {'cmd.run_all': mock}):
            self.assertTrue(npm.cache_clean('coffee-script'))
Example #2
0
    def test_cache_clean(self):
        """
        Test if it cleans the cached NPM packages.
        """
        mock = MagicMock(return_value={"retcode": 1, "stderr": "error"})
        with patch.dict(npm.__salt__, {"cmd.run_all": mock}):
            self.assertFalse(npm.cache_clean())

        mock = MagicMock(return_value={"retcode": 0})
        with patch.dict(npm.__salt__, {"cmd.run_all": mock}):
            self.assertTrue(npm.cache_clean())

        mock = MagicMock(return_value={"retcode": 0})
        with patch.dict(npm.__salt__, {"cmd.run_all": mock}):
            self.assertTrue(npm.cache_clean("coffee-script"))