c2af52f6bcb1aeb78ac372b70ca07d386b693f72
[osm/common.git] / osm_common / tests / test_dbbase.py
1 import http
2 import pytest
3
4 from osm_common.dbbase import DbBase, DbException
5
6
7 def exception_message(message):
8 return "database exception " + message
9
10
11 @pytest.fixture
12 def db_base():
13 return DbBase()
14
15
16 def test_constructor():
17 db_base = DbBase()
18 assert db_base is not None
19 assert isinstance(db_base, DbBase)
20
21
22 def test_db_connect(db_base):
23 db_base.db_connect(None)
24
25
26 def test_db_disconnect(db_base):
27 db_base.db_disconnect()
28
29
30 def test_get_list(db_base):
31 with pytest.raises(DbException) as excinfo:
32 db_base.get_list(None, None)
33 assert str(excinfo.value).startswith(exception_message("Method 'get_list' not implemented"))
34 assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND
35
36
37 def test_get_one(db_base):
38 with pytest.raises(DbException) as excinfo:
39 db_base.get_one(None, None, None, None)
40 assert str(excinfo.value).startswith(exception_message("Method 'get_one' not implemented"))
41 assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND
42
43
44 def test_create(db_base):
45 with pytest.raises(DbException) as excinfo:
46 db_base.create(None, None)
47 assert str(excinfo.value).startswith(exception_message("Method 'create' not implemented"))
48 assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND
49
50
51 def test_del_list(db_base):
52 with pytest.raises(DbException) as excinfo:
53 db_base.del_list(None, None)
54 assert str(excinfo.value).startswith(exception_message("Method 'del_list' not implemented"))
55 assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND
56
57
58 def test_del_one(db_base):
59 with pytest.raises(DbException) as excinfo:
60 db_base.del_one(None, None, None)
61 assert str(excinfo.value).startswith(exception_message("Method 'del_one' not implemented"))
62 assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND