def test_list_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.list_(bank='', cachedir=''), [])
def test_list_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.list_(bank="", cachedir=""), [])
def test_list_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.list_(bank='bank', cachedir=tmp_dir), ['key'])
def test_list_success(self): """ Tests the return of the ls function containing bank entries. """ # Create a temporary cache dir tmp_dir = tempfile.mkdtemp(dir=RUNTIME_VARS.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.list_(bank="bank", cachedir=tmp_dir), ["key"])
def test_list_no_base_dir(self): ''' Tests that the list function returns an empty list if the bank directory doesn't exist. ''' self.assertEqual(localfs.list_(bank='', cachedir=''), [])