test_backend.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from __future__ import absolute_import, unicode_literals
  2. import os
  3. from case import skip
  4. from celery.backends.azureblockblob import AzureBlockBlobBackend
  5. @skip.unless_module("azure")
  6. @skip.unless_environ("AZUREBLOCKBLOB_URL")
  7. class test_AzureBlockBlobBackend:
  8. def test_crud(self, manager):
  9. backend = AzureBlockBlobBackend(
  10. app=manager.app,
  11. url=os.environ["AZUREBLOCKBLOB_URL"])
  12. key_values = {("akey%d" % i).encode(): "avalue%d" % i
  13. for i in range(5)}
  14. for key, value in key_values.items():
  15. backend.set(key, value)
  16. actual_values = backend.mget(key_values.keys())
  17. expected_values = list(key_values.values())
  18. assert expected_values == actual_values
  19. for key in key_values:
  20. backend.delete(key)
  21. def test_get_missing(self, manager):
  22. backend = AzureBlockBlobBackend(
  23. app=manager.app,
  24. url=os.environ["AZUREBLOCKBLOB_URL"])
  25. assert backend.get(b"doesNotExist") is None