Skip to content

Commit

Permalink
Update test_handlers.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaudinFlorence committed Mar 18, 2024
1 parent 5b4a141 commit 8c6e88d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions jupyter_drives/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand All @@ -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")
Expand All @@ -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
Expand All @@ -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

0 comments on commit 8c6e88d

Please sign in to comment.