Ejemplo n.º 1
0
 def test_ls_no_base_dir(self):
     '''
     Tests that the ls function returns an empty list if the bank directory
     doesn't exist.
     '''
     with patch('os.path.isdir', MagicMock(return_value=False)):
         self.assertEqual(localfs.ls(bank='', cachedir=''), [])
Ejemplo n.º 2
0
    def test_ls_success(self):
        '''
        Tests the return of the ls function containing bank entries.
        '''
        # Create a temporary cache dir
        tmp_dir = tempfile.mkdtemp(dir=TMP)

        # Use the helper function to create the cache file using localfs.store()
        self._create_tmp_cache_file(tmp_dir, salt.payload.Serial(self))

        # Now test the return of the ls function
        with patch.dict(localfs.__opts__, {'cachedir': tmp_dir}):
            self.assertEqual(localfs.ls(bank='bank', cachedir=tmp_dir), ['key'])
Ejemplo n.º 3
0
 def test_ls_no_base_dir(self):
     '''
     Tests that the ls function returns an empty list if the bank directory
     doesn't exist.
     '''
     self.assertEqual(localfs.ls(bank='', cachedir=''), [])