| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# coding=utf-8 |
| 3 |
# -------------------------------------------------------------------------- |
| 4 |
# Copyright (c) Microsoft Corporation. All rights reserved. |
| 5 |
# Licensed under the MIT License. See License.txt in the project root for |
| 6 |
# license information. |
| 7 |
# -------------------------------------------------------------------------- |
| 8 |
|
| 9 |
import pytest |
| 10 |
import time |
| 11 |
|
| 12 |
from azure.datalake.store.exceptions import DatalakeRESTException |
| 13 |
from azure.datalake.store.lib import (DatalakeRESTInterface) |
| 14 |
|
| 15 |
from tests import settings |
| 16 |
from tests.testing import my_vcr |
| 17 |
|
| 18 |
@pytest.fixture() |
| 19 |
def token(): |
| 20 |
return settings.TOKEN_CREDEDENTIAL |
| 21 |
|
| 22 |
@pytest.fixture() |
| 23 |
def rest(token): |
| 24 |
return DatalakeRESTInterface(settings.STORE_NAME, token) |
| 25 |
|
| 26 |
def test_errors(token): |
| 27 |
no_rest = DatalakeRESTInterface("none", token) |
| 28 |
|
| 29 |
with pytest.raises(ValueError): |
| 30 |
# no such op |
| 31 |
no_rest.call('NONEXISTENT') |
| 32 |
|
| 33 |
with pytest.raises(ValueError): |
| 34 |
# too few parameters |
| 35 |
no_rest.call("RENAME") |
| 36 |
|
| 37 |
with pytest.raises(ValueError): |
| 38 |
# too many parameters |
| 39 |
no_rest.call('RENAME', many='', additional='', pars='') |
| 40 |
|
| 41 |
with pytest.raises(DatalakeRESTException): |
| 42 |
# no such store |
| 43 |
no_rest.call('GETCONTENTSUMMARY') |
| 44 |
|
| 45 |
|
| 46 |
@my_vcr.use_cassette |
| 47 |
def test_response(rest): |
| 48 |
out = rest.call('LISTSTATUS', '') |
| 49 |
assert out |