1
0

test_s3fs.py 1005 B

123456789101112131415161718192021222324252627282930
  1. import tempfile
  2. import salt.fileserver.s3fs as s3fs
  3. from tests.support.mixins import LoaderModuleMockMixin
  4. from tests.support.runtests import RUNTIME_VARS
  5. from tests.support.unit import TestCase
  6. class S3fsFileTest(TestCase, LoaderModuleMockMixin):
  7. def setup_loader_modules(self):
  8. opts = {
  9. "cachedir": self.tmp_cachedir,
  10. }
  11. return {s3fs: {"__opts__": opts}}
  12. @classmethod
  13. def setUpClass(cls):
  14. cls.tmp_cachedir = tempfile.mkdtemp(dir=RUNTIME_VARS.TMP)
  15. def test_cache_round_trip(self):
  16. metadata = {"foo": "bar"}
  17. cache_file = s3fs._get_cached_file_name("base", "fake_bucket", "some_file")
  18. s3fs._write_buckets_cache_file(metadata, cache_file)
  19. assert s3fs._read_buckets_cache_file(cache_file) == metadata
  20. def test_ignore_pickle_load_exceptions(self):
  21. # TODO: parameterized test with patched pickle.load that raises the
  22. # various allowable exception from _read_buckets_cache_file
  23. pass