4 from osm_common
.dbbase
import DbBase
, DbException
7 def exception_message(message
):
8 return "database exception " + message
16 def test_constructor():
18 assert db_base
is not None
19 assert isinstance(db_base
, DbBase
)
22 def test_db_connect(db_base
):
23 db_base
.db_connect(None)
26 def test_db_disconnect(db_base
):
27 db_base
.db_disconnect()
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
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
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
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
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