conftest.py 942 B

12345678910111213141516171819202122232425262728293031323334353637
  1. """
  2. bucketstore pytest configuration
  3. """
  4. import bucketstore
  5. import os
  6. import pytest
  7. from moto import mock_s3
  8. from typing import Generator
  9. # this is to attempt to hack our way around boto issues
  10. os.environ["AWS_DEFAULT_REGION"] = "us-east-1"
  11. os.environ["AWS_SECURITY_TOKEN"] = "testing"
  12. os.environ["AWS_SESSION_TOKEN"] = "testing"
  13. @pytest.fixture(autouse=True)
  14. def login() -> Generator:
  15. """fixture that will automatically set the login variables."""
  16. bucketstore.login("access_key", "secret_key")
  17. yield
  18. @pytest.fixture
  19. def bucket() -> Generator:
  20. """fixture that provides a bucketstore bucket."""
  21. with mock_s3():
  22. yield bucketstore.get("bucketstore-playground", create=True)
  23. @pytest.fixture
  24. def key(bucket: bucketstore.S3Bucket) -> bucketstore.S3Key:
  25. """fixture that provides a key inside of the given bucket"""
  26. name = "testing-key"
  27. bucket.set(name, "a testing value")
  28. return bucket.key(name)