Ejemplo n.º 1
0
def test_upload_action_existing_file():
    storage = MockExternalStorageBackend()
    adapter = basic_external.BasicExternalBackendTransferAdapter(storage, 900)

    # Add an "existing object"
    storage.existing_objects[('myorg/myrepo', 'abcdef123456')] = 1234

    response = adapter.upload('myorg', 'myrepo', 'abcdef123456', 1234)

    # We expect a response with no actions
    assert response == {
        "oid": 'abcdef123456',
        "size": 1234,
    }
Ejemplo n.º 2
0
def test_download_action_size_mismatch():
    storage = MockExternalStorageBackend()
    adapter = basic_external.BasicExternalBackendTransferAdapter(storage, 900)

    # Add an "existing object"
    storage.existing_objects[('myorg/myrepo', 'abcdef123456')] = 1234
    response = adapter.download('myorg', 'myrepo', 'abcdef123456', 12345)

    assert response == {
        "oid": 'abcdef123456',
        "size": 12345,
        "error": {
            "code": 422,
            "message": "Object size does not match"
        }
    }
Ejemplo n.º 3
0
def test_download_action_existing_file():
    storage = MockExternalStorageBackend()
    adapter = basic_external.BasicExternalBackendTransferAdapter(storage, 900)

    # Add an "existing object"
    storage.existing_objects[('myorg/myrepo', 'abcdef123456')] = 1234
    response = adapter.download('myorg', 'myrepo', 'abcdef123456', 1234)

    assert response == {
        "oid": 'abcdef123456',
        "size": 1234,
        "authenticated": True,
        "actions": {
            "download": {
                "href":
                'https://cloudstorage.example.com/myorg/myrepo/abcdef123456?expires_in=900',
                "header": {},
                "expires_in": 900
            }
        }
    }