You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
842 B

5 years ago
5 years ago
  1. import pytest
  2. from pathlib import Path
  3. from tibi_hardlinks.cache import Cache
  4. def test_cache_init(tmp_path):
  5. Cache(tmp_path)
  6. def test_cache_store(tmp_path):
  7. Cache(tmp_path).store()
  8. def test_cache_load(tmp_path):
  9. Cache(tmp_path).store()
  10. Cache(tmp_path).load()
  11. def test_cache_read_write(tmp_path):
  12. c = Cache(tmp_path)
  13. c.write("key", "val")
  14. assert c.read("key") == "val"
  15. def test_cache_write_store_load_read(tmp_path):
  16. c = Cache(tmp_path)
  17. c.write("key", "val")
  18. c.store()
  19. c_load = Cache(tmp_path)
  20. assert c_load.read("key") == "val"
  21. def test_cache_write_store_load_read_with_dict(tmp_path):
  22. c = Cache(tmp_path)
  23. c.write("key", {"key": "val"})
  24. c.store()
  25. c_load = Cache(tmp_path)
  26. assert isinstance(c_load.read("key"), dict)
  27. assert c_load.read("key")["key"] == "val"