From 8c6e88d03f8713a69699e8eafecf2a3f7c11c0f8 Mon Sep 17 00:00:00 2001 From: HaudinFlorence Date: Mon, 18 Mar 2024 11:17:30 +0100 Subject: [PATCH] Update test_handlers.py. --- jupyter_drives/tests/test_handlers.py | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/jupyter_drives/tests/test_handlers.py b/jupyter_drives/tests/test_handlers.py index 6d81029..f7842da 100644 --- a/jupyter_drives/tests/test_handlers.py +++ b/jupyter_drives/tests/test_handlers.py @@ -6,7 +6,7 @@ import os -from moto import mock_s3 +from moto import mock_aws from moto.moto_server.threaded_moto_server import ThreadedMotoServer from libcloud.storage.types import Provider from libcloud.storage.providers import get_driver @@ -17,20 +17,20 @@ def s3_base(): os.environ["access_key_id"] = 'access_key' os.environ["secret_access_key"] = 'secret_key' - with mock_s3(): + with mock_aws(): S3Drive = get_driver(Provider.S3) drive = S3Drive('access_key', 'secret_key') - + print('drive:', drive) yield drive @pytest.mark.skip(reason="FIX") async def test_ListJupyterDrives_s3_success(jp_fetch, s3_base): - with mock_s3(): + with mock_aws(): # extract S3 drive drive = s3_base - test_bucket_name_1 = "jupyter-drives-test-bucket-1" - test_bucket_name_2 = "jupyter-drives-test-bucket-2" + test_bucket_name_1 = "jupyter-drive-bucket1" + test_bucket_name_2 = "jupyter-drive-bucket2" # Create some test containers drive.create_container(test_bucket_name_1) @@ -42,11 +42,11 @@ async def test_ListJupyterDrives_s3_success(jp_fetch, s3_base): # Then assert response.code == 200 payload = json.loads(response.body) - assert "jupyter-drives-test-bucket-1" in payload["data"] - assert "jupyter-drives-test-bucket-2" in payload["data"] + assert "jupyter-drive-bucket1" in payload["data"] + assert "jupyter-drive-bucket2" in payload["data"] async def test_ListJupyterDrives_s3_empty_list(jp_fetch, s3_base): - with mock_s3(): + with mock_aws(): # extract S3 drive drive = s3_base @@ -60,7 +60,7 @@ async def test_ListJupyterDrives_s3_empty_list(jp_fetch, s3_base): @pytest.mark.skip(reason="FIX") async def test_ListJupyterDrives_s3_missing_credentials(jp_fetch, s3_base): - with mock_s3(): + with mock_aws(): # When with pytest.raises(tornado.web.HTTPError) as exc_info: response = await jp_fetch("jupyter-drives", "drives") @@ -70,11 +70,11 @@ async def test_ListJupyterDrives_s3_missing_credentials(jp_fetch, s3_base): @pytest.mark.skip(reason="FIX") async def test_MountJupyterDriveHandler(jp_fetch, s3_base): - with mock_s3(): + with mock_aws(): drive = s3_base # Create test container to mount - test_bucket_name_1 = "jupyter-drives-test-bucket-1" + test_bucket_name_1 = "jupyter-drive-bucket1" drive.create_container(test_bucket_name_1) # When @@ -85,16 +85,16 @@ async def test_MountJupyterDriveHandler(jp_fetch, s3_base): @pytest.mark.skip(reason="ToBeImplemented") async def test_UnmountJupyterDriveHandler(jp_fetch, s3_base): - with mock_s3(): + with mock_aws(): # extract S3 drive drive = s3_base # Create test container to mount - test_bucket_name_1 = "jupyter-drives-test-bucket-1" + test_bucket_name_1 = "jupyter-drive-bucket1" drive.create_container(test_bucket_name_1) # When - body = {"drive_name": "jupyter-drives-test-bucket-1", "mount_drive": "false" } + body = {"drive_name": "jupyter-drive-bucket1", "mount_drive": "false" } response = await jp_fetch("jupyter-drives", "drives", body = json.dumps(body), method = "POST") assert response["code"] == 204