Skip to content

Commit

Permalink
Merge pull request #72 from filswan/testUpdate/addDeleteAllBucketAfte…
Browse files Browse the repository at this point in the history
…rTest

Update conftest.py
  • Loading branch information
PlutoNbai authored Sep 20, 2023
2 parents d131189 + 040cff5 commit 658328c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from swan_mcs.object.bucket_storage import Bucket

abs_path = os.path.dirname(os.path.abspath(__file__))
load_dotenv(abs_path + '/.env_test')
load_dotenv(abs_path + '/.env')
api_key = os.getenv('api_key')
access_token = os.getenv('access_token')
chain_name = os.getenv('chain_name')
Expand Down Expand Up @@ -219,3 +219,16 @@ def temp_dir():
yield dirpath
# teardown - remove directory after all tests complete
shutil.rmtree(dirpath)


@pytest.fixture(scope="module", autouse=True)
def delete_all_buckets():
bucket_api = BucketAPI(APIClient(api_key, access_token, chain_name))
buckets = bucket_api.list_buckets()
for bucket in buckets:
bucket_api.delete_bucket(bucket.bucket_name)
print("Deleted bucket: ", bucket.bucket_name)


def pytest_sessionfinish(session, exitstatus):
delete_all_buckets()

0 comments on commit 658328c

Please sign in to comment.