示例#1
0
 def test_flush_key_provided_and_no_key_file_false(self):
     '''
     Tests that the flush function returns False when a key file is provided but
     the target key file doesn't exist in the cache bank.
     '''
     with patch('os.path.isfile', MagicMock(return_value=False)):
         self.assertFalse(localfs.flush(bank='', key='key', cachedir=''))
示例#2
0
 def test_flush_key_is_none_and_no_target_dir(self):
     '''
     Tests that the flush function returns False when no key is passed in and the
     target directory doesn't exist.
     '''
     with patch('os.path.isdir', MagicMock(return_value=False)):
         self.assertFalse(localfs.flush(bank='', key=None, cachedir=''))
示例#3
0
 def test_flush_key_provided_and_no_key_file_false(self):
     """
     Tests that the flush function returns False when a key file is provided but
     the target key file doesn't exist in the cache bank.
     """
     with patch("os.path.isfile", MagicMock(return_value=False)):
         self.assertFalse(localfs.flush(bank="", key="key", cachedir=""))
示例#4
0
    def test_flush_success(self):
        """
        Tests that the flush function returns True when a key file is provided and
        the target key exists in the cache bank.
        """
        # Create a temporary cache dir
        tmp_dir = tempfile.mkdtemp(dir=integration.SYS_TMP_DIR)

        # 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 flush function
        with patch.dict(localfs.__opts__, {"cachedir": tmp_dir}):
            self.assertTrue(localfs.flush(bank="bank", key="key"))
示例#5
0
    def test_flush_success(self):
        '''
        Tests that the flush function returns True when a key file is provided and
        the target key exists in the cache bank.
        '''
        # Create a temporary cache dir
        tmp_dir = tempfile.mkdtemp(dir=integration.SYS_TMP_DIR)

        # 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 flush function
        with patch.dict(localfs.__opts__, {'cachedir': tmp_dir}):
            self.assertTrue(localfs.flush(bank='bank', key='key'))
示例#6
0
    def test_flush_success(self):
        """
        Tests that the flush function returns True when a key file is provided and
        the target key exists in the cache bank.
        """
        with patch("os.path.isfile", MagicMock(return_value=True)):
            # 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 flush function
            with patch.dict(localfs.__opts__, {"cachedir": tmp_dir}):
                self.assertTrue(localfs.flush(bank="bank", key="key", cachedir=tmp_dir))
示例#7
0
 def test_flush_key_provided_and_no_key_file_false(self):
     '''
     Tests that the flush function returns False when a key file is provided but
     the target key file doesn't exist in the cache bank.
     '''
     self.assertFalse(localfs.flush(bank='', key='key', cachedir=''))
示例#8
0
 def test_flush_key_is_none_and_no_target_dir(self):
     '''
     Tests that the flush function returns False when no key is passed in and the
     target directory doesn't exist.
     '''
     self.assertFalse(localfs.flush(bank='', key=None, cachedir=''))
示例#9
0
 def test_flush_key_provided_and_no_key_file_false(self):
     """
     Tests that the flush function returns False when a key file is provided but
     the target key file doesn't exist in the cache bank.
     """
     self.assertFalse(localfs.flush(bank="", key="key"))
示例#10
0
 def test_flush_key_is_none_and_no_target_dir(self):
     """
     Tests that the flush function returns False when no key is passed in and the
     target directory doesn't exist.
     """
     self.assertFalse(localfs.flush(bank="", key=None))