Exemple #1
0
 def test_updated_return_when_cache_file_does_not_exist(self):
     '''
     Tests that the updated function returns None when the cache key file doesn't
     exist.
     '''
     with patch('os.path.isfile', MagicMock(return_value=False)):
         self.assertIsNone(localfs.updated(bank='', key='', cachedir=''))
Exemple #2
0
 def test_updated_return_when_cache_file_does_not_exist(self):
     """
     Tests that the updated function returns None when the cache key file doesn't
     exist.
     """
     with patch("os.path.isfile", MagicMock(return_value=False)):
         self.assertIsNone(localfs.updated(bank="", key="", cachedir=""))
Exemple #3
0
    def test_updated_success(self):
        """
        Test that the updated function returns the modification time of the cache file
        """
        # 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))

        with patch("os.path.join", MagicMock(return_value=tmp_dir + "/bank/key.p")):
            self.assertIsInstance(localfs.updated(bank="bank", key="key"), int)
Exemple #4
0
    def test_updated_success(self):
        '''
        Test that the updated function returns the modification time of the cache file
        '''
        # 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))

        with patch('os.path.join', MagicMock(return_value=tmp_dir + '/bank/key.p')):
            self.assertIsInstance(localfs.updated(bank='bank', key='key', cachedir=tmp_dir), int)
Exemple #5
0
    def test_updated_success(self):
        """
        Test that the updated function returns the modification time of the cache file
        """
        # 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))

        with patch("os.path.join", MagicMock(return_value=tmp_dir + "/bank/key.p")):
            self.assertIsInstance(
                localfs.updated(bank="bank", key="key", cachedir=tmp_dir), int
            )
Exemple #6
0
 def test_updated_return_when_cache_file_does_not_exist(self):
     '''
     Tests that the updated function returns None when the cache key file doesn't
     exist.
     '''
     self.assertIsNone(localfs.updated(bank='', key='', cachedir=''))
Exemple #7
0
 def test_updated_return_when_cache_file_does_not_exist(self):
     """
     Tests that the updated function returns None when the cache key file doesn't
     exist.
     """
     self.assertIsNone(localfs.updated(bank="", key=""))