4 from osm_common
.dbbase
import DbBase
, DbException
6 def exception_message(message
):
7 return "database exception " + message
13 def test_constructor():
16 assert db_base
!= None
17 assert isinstance(db_base
, DbBase
)
19 def test_db_connect(db_base
):
20 db_base
.db_connect(None)
22 def test_db_disconnect(db_base
):
23 db_base
.db_disconnect()
25 def test_get_list(db_base
):
26 with pytest
.raises(DbException
) as excinfo
:
27 db_base
.get_list(None, None)
28 assert str(excinfo
.value
).startswith(exception_message("Method 'get_list' not implemented"))
29 assert excinfo
.value
.http_code
== http
.HTTPStatus
.NOT_FOUND
31 def test_get_one(db_base
):
32 with pytest
.raises(DbException
) as excinfo
:
33 db_base
.get_one(None, None, None, None)
34 assert str(excinfo
.value
).startswith(exception_message("Method 'get_one' not implemented"))
35 assert excinfo
.value
.http_code
== http
.HTTPStatus
.NOT_FOUND
37 def test_create(db_base
):
38 with pytest
.raises(DbException
) as excinfo
:
39 db_base
.create(None, None)
40 assert str(excinfo
.value
).startswith(exception_message("Method 'create' not implemented"))
41 assert excinfo
.value
.http_code
== http
.HTTPStatus
.NOT_FOUND
43 def test_del_list(db_base
):
44 with pytest
.raises(DbException
) as excinfo
:
45 db_base
.del_list(None, None)
46 assert str(excinfo
.value
).startswith(exception_message("Method 'del_list' not implemented"))
47 assert excinfo
.value
.http_code
== http
.HTTPStatus
.NOT_FOUND
49 def test_del_one(db_base
):
50 with pytest
.raises(DbException
) as excinfo
:
51 db_base
.del_one(None, None, None)
52 assert str(excinfo
.value
).startswith(exception_message("Method 'del_one' not implemented"))
53 assert excinfo
.value
.http_code
== http
.HTTPStatus
.NOT_FOUND