4 from osm_common
.fsbase
import FsBase
, FsException
6 def exception_message(message
):
7 return "storage exception " + message
13 def test_constructor():
16 assert fs_base
!= None
17 assert isinstance(fs_base
, FsBase
)
19 def test_get_params(fs_base
):
20 params
= fs_base
.get_params()
22 assert isinstance(params
, dict)
23 assert len(params
) == 0
25 def test_fs_connect(fs_base
):
26 fs_base
.fs_connect(None)
28 def test_fs_disconnect(fs_base
):
29 fs_base
.fs_disconnect()
31 def test_mkdir(fs_base
):
32 with pytest
.raises(FsException
) as excinfo
:
34 assert str(excinfo
.value
).startswith(exception_message("Method 'mkdir' not implemented"))
35 assert excinfo
.value
.http_code
== http
.HTTPStatus
.INTERNAL_SERVER_ERROR
37 def test_file_exists(fs_base
):
38 with pytest
.raises(FsException
) as excinfo
:
39 fs_base
.file_exists(None)
40 assert str(excinfo
.value
).startswith(exception_message("Method 'file_exists' not implemented"))
41 assert excinfo
.value
.http_code
== http
.HTTPStatus
.INTERNAL_SERVER_ERROR
43 def test_file_size(fs_base
):
44 with pytest
.raises(FsException
) as excinfo
:
45 fs_base
.file_size(None)
46 assert str(excinfo
.value
).startswith(exception_message("Method 'file_size' not implemented"))
47 assert excinfo
.value
.http_code
== http
.HTTPStatus
.INTERNAL_SERVER_ERROR
49 def test_file_extract(fs_base
):
50 with pytest
.raises(FsException
) as excinfo
:
51 fs_base
.file_extract(None, None)
52 assert str(excinfo
.value
).startswith(exception_message("Method 'file_extract' not implemented"))
53 assert excinfo
.value
.http_code
== http
.HTTPStatus
.INTERNAL_SERVER_ERROR
55 def test_file_open(fs_base
):
56 with pytest
.raises(FsException
) as excinfo
:
57 fs_base
.file_open(None, None)
58 assert str(excinfo
.value
).startswith(exception_message("Method 'file_open' not implemented"))
59 assert excinfo
.value
.http_code
== http
.HTTPStatus
.INTERNAL_SERVER_ERROR
61 def test_file_delete(fs_base
):
62 with pytest
.raises(FsException
) as excinfo
:
63 fs_base
.file_delete(None, None)
64 assert str(excinfo
.value
).startswith(exception_message("Method 'file_delete' not implemented"))
65 assert excinfo
.value
.http_code
== http
.HTTPStatus
.INTERNAL_SERVER_ERROR