a789297804e0109b68c3a2d4e99b50783edde14e
[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 def exception_message(message):
7 return "storage exception " + message
8
9 @pytest.fixture
10 def fs_base():
11 return FsBase()
12
13 def test_constructor():
14 fs_base = FsBase()
15
16 assert fs_base != None
17 assert isinstance(fs_base, FsBase)
18
19 def test_get_params(fs_base):
20 params = fs_base.get_params()
21
22 assert isinstance(params, dict)
23 assert len(params) == 0
24
25 def test_fs_connect(fs_base):
26 fs_base.fs_connect(None)
27
28 def test_fs_disconnect(fs_base):
29 fs_base.fs_disconnect()
30
31 def test_mkdir(fs_base):
32 with pytest.raises(FsException) as excinfo:
33 fs_base.mkdir(None)
34 assert str(excinfo.value).startswith(exception_message("Method 'mkdir' not implemented"))
35 assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
36
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
42
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
48
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
54
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
60
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