e545343cd3783b688dba7d1ec2fdc9088100ba99
[osm/common.git] / osm_common / tests / test_fsbase.py
1 import http
2 import pytest
3
4 from osm_common.fsbase import FsBase, FsException
5
6
7 def exception_message(message):
8 return "storage exception " + message
9
10
11 @pytest.fixture
12 def fs_base():
13 return FsBase()
14
15
16 def test_constructor():
17 fs_base = FsBase()
18 assert fs_base is not None
19 assert isinstance(fs_base, FsBase)
20
21
22 def test_get_params(fs_base):
23 params = fs_base.get_params()
24 assert isinstance(params, dict)
25 assert len(params) == 0
26
27
28 def test_fs_connect(fs_base):
29 fs_base.fs_connect(None)
30
31
32 def test_fs_disconnect(fs_base):
33 fs_base.fs_disconnect()
34
35
36 def test_mkdir(fs_base):
37 with pytest.raises(FsException) as excinfo:
38 fs_base.mkdir(None)
39 assert str(excinfo.value).startswith(exception_message("Method 'mkdir' not implemented"))
40 assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
41
42
43 def test_file_exists(fs_base):
44 with pytest.raises(FsException) as excinfo:
45 fs_base.file_exists(None)
46 assert str(excinfo.value).startswith(exception_message("Method 'file_exists' not implemented"))
47 assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
48
49
50 def test_file_size(fs_base):
51 with pytest.raises(FsException) as excinfo:
52 fs_base.file_size(None)
53 assert str(excinfo.value).startswith(exception_message("Method 'file_size' not implemented"))
54 assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
55
56
57 def test_file_extract(fs_base):
58 with pytest.raises(FsException) as excinfo:
59 fs_base.file_extract(None, None)
60 assert str(excinfo.value).startswith(exception_message("Method 'file_extract' not implemented"))
61 assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
62
63
64 def test_file_open(fs_base):
65 with pytest.raises(FsException) as excinfo:
66 fs_base.file_open(None, None)
67 assert str(excinfo.value).startswith(exception_message("Method 'file_open' not implemented"))
68 assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
69
70
71 def test_file_delete(fs_base):
72 with pytest.raises(FsException) as excinfo:
73 fs_base.file_delete(None, None)
74 assert str(excinfo.value).startswith(exception_message("Method 'file_delete' not implemented"))
75 assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR