1 |
|
# Copyright 2018 Whitestack, LLC |
2 |
|
# Copyright 2018 Telefonica S.A. |
3 |
|
# |
4 |
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
5 |
|
# not use this file except in compliance with the License. You may obtain |
6 |
|
# a copy of the License at |
7 |
|
# |
8 |
|
# http://www.apache.org/licenses/LICENSE-2.0 |
9 |
|
# |
10 |
|
# Unless required by applicable law or agreed to in writing, software |
11 |
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
12 |
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
13 |
|
# License for the specific language governing permissions and limitations |
14 |
|
# under the License. |
15 |
|
# |
16 |
|
# For those usages not covered by the Apache License, Version 2.0 please |
17 |
|
# contact: esousa@whitestack.com or alfonso.tiernosepulveda@telefonica.com |
18 |
|
## |
19 |
|
|
20 |
1 |
import http |
21 |
|
|
22 |
1 |
from osm_common.fsbase import FsBase, FsException |
23 |
1 |
import pytest |
24 |
|
|
25 |
|
|
26 |
1 |
def exception_message(message): |
27 |
0 |
return "storage exception " + message |
28 |
|
|
29 |
|
|
30 |
1 |
@pytest.fixture |
31 |
1 |
def fs_base(): |
32 |
0 |
return FsBase() |
33 |
|
|
34 |
|
|
35 |
1 |
def test_constructor(): |
36 |
1 |
fs_base = FsBase() |
37 |
1 |
assert fs_base is not None |
38 |
1 |
assert isinstance(fs_base, FsBase) |
39 |
|
|
40 |
|
|
41 |
1 |
def test_get_params(fs_base): |
42 |
0 |
params = fs_base.get_params() |
43 |
0 |
assert isinstance(params, dict) |
44 |
0 |
assert len(params) == 0 |
45 |
|
|
46 |
|
|
47 |
1 |
def test_fs_connect(fs_base): |
48 |
0 |
fs_base.fs_connect(None) |
49 |
|
|
50 |
|
|
51 |
1 |
def test_fs_disconnect(fs_base): |
52 |
0 |
fs_base.fs_disconnect() |
53 |
|
|
54 |
|
|
55 |
1 |
def test_mkdir(fs_base): |
56 |
0 |
with pytest.raises(FsException) as excinfo: |
57 |
0 |
fs_base.mkdir(None) |
58 |
0 |
assert str(excinfo.value).startswith( |
59 |
|
exception_message("Method 'mkdir' not implemented") |
60 |
|
) |
61 |
0 |
assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR |
62 |
|
|
63 |
|
|
64 |
1 |
def test_file_exists(fs_base): |
65 |
0 |
with pytest.raises(FsException) as excinfo: |
66 |
0 |
fs_base.file_exists(None) |
67 |
0 |
assert str(excinfo.value).startswith( |
68 |
|
exception_message("Method 'file_exists' not implemented") |
69 |
|
) |
70 |
0 |
assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR |
71 |
|
|
72 |
|
|
73 |
1 |
def test_file_size(fs_base): |
74 |
0 |
with pytest.raises(FsException) as excinfo: |
75 |
0 |
fs_base.file_size(None) |
76 |
0 |
assert str(excinfo.value).startswith( |
77 |
|
exception_message("Method 'file_size' not implemented") |
78 |
|
) |
79 |
0 |
assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR |
80 |
|
|
81 |
|
|
82 |
1 |
def test_file_extract(fs_base): |
83 |
0 |
with pytest.raises(FsException) as excinfo: |
84 |
0 |
fs_base.file_extract(None, None) |
85 |
0 |
assert str(excinfo.value).startswith( |
86 |
|
exception_message("Method 'file_extract' not implemented") |
87 |
|
) |
88 |
0 |
assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR |
89 |
|
|
90 |
|
|
91 |
1 |
def test_file_open(fs_base): |
92 |
0 |
with pytest.raises(FsException) as excinfo: |
93 |
0 |
fs_base.file_open(None, None) |
94 |
0 |
assert str(excinfo.value).startswith( |
95 |
|
exception_message("Method 'file_open' not implemented") |
96 |
|
) |
97 |
0 |
assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR |
98 |
|
|
99 |
|
|
100 |
1 |
def test_file_delete(fs_base): |
101 |
0 |
with pytest.raises(FsException) as excinfo: |
102 |
0 |
fs_base.file_delete(None, None) |
103 |
0 |
assert str(excinfo.value).startswith( |
104 |
|
exception_message("Method 'file_delete' not implemented") |
105 |
|
) |
106 |
0 |
assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR |