--- /dev/null
+import http
+import pytest
+
+from osm_common.dbbase import DbBase, DbException
+
+def exception_message(message):
+ return "database exception " + message
+
+@pytest.fixture
+def db_base():
+ return DbBase()
+
+def test_constructor():
+ db_base = DbBase()
+
+ assert db_base != None
+ assert isinstance(db_base, DbBase)
+
+def test_db_connect(db_base):
+ db_base.db_connect(None)
+
+def test_db_disconnect(db_base):
+ db_base.db_disconnect()
+
+def test_get_list(db_base):
+ with pytest.raises(DbException) as excinfo:
+ db_base.get_list(None, None)
+ assert str(excinfo.value).startswith(exception_message("Method 'get_list' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND
+
+def test_get_one(db_base):
+ with pytest.raises(DbException) as excinfo:
+ db_base.get_one(None, None, None, None)
+ assert str(excinfo.value).startswith(exception_message("Method 'get_one' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND
+
+def test_create(db_base):
+ with pytest.raises(DbException) as excinfo:
+ db_base.create(None, None)
+ assert str(excinfo.value).startswith(exception_message("Method 'create' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND
+
+def test_del_list(db_base):
+ with pytest.raises(DbException) as excinfo:
+ db_base.del_list(None, None)
+ assert str(excinfo.value).startswith(exception_message("Method 'del_list' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND
+
+def test_del_one(db_base):
+ with pytest.raises(DbException) as excinfo:
+ db_base.del_one(None, None, None)
+ assert str(excinfo.value).startswith(exception_message("Method 'del_one' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND
--- /dev/null
+import http
+import pytest
+
+from osm_common.fsbase import FsBase, FsException
+
+def exception_message(message):
+ return "storage exception " + message
+
+@pytest.fixture
+def fs_base():
+ return FsBase()
+
+def test_constructor():
+ fs_base = FsBase()
+
+ assert fs_base != None
+ assert isinstance(fs_base, FsBase)
+
+def test_get_params(fs_base):
+ params = fs_base.get_params()
+
+ assert isinstance(params, dict)
+ assert len(params) == 0
+
+def test_fs_connect(fs_base):
+ fs_base.fs_connect(None)
+
+def test_fs_disconnect(fs_base):
+ fs_base.fs_disconnect()
+
+def test_mkdir(fs_base):
+ with pytest.raises(FsException) as excinfo:
+ fs_base.mkdir(None)
+ assert str(excinfo.value).startswith(exception_message("Method 'mkdir' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
+
+def test_file_exists(fs_base):
+ with pytest.raises(FsException) as excinfo:
+ fs_base.file_exists(None)
+ assert str(excinfo.value).startswith(exception_message("Method 'file_exists' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
+
+def test_file_size(fs_base):
+ with pytest.raises(FsException) as excinfo:
+ fs_base.file_size(None)
+ assert str(excinfo.value).startswith(exception_message("Method 'file_size' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
+
+def test_file_extract(fs_base):
+ with pytest.raises(FsException) as excinfo:
+ fs_base.file_extract(None, None)
+ assert str(excinfo.value).startswith(exception_message("Method 'file_extract' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
+
+def test_file_open(fs_base):
+ with pytest.raises(FsException) as excinfo:
+ fs_base.file_open(None, None)
+ assert str(excinfo.value).startswith(exception_message("Method 'file_open' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
+
+def test_file_delete(fs_base):
+ with pytest.raises(FsException) as excinfo:
+ fs_base.file_delete(None, None)
+ assert str(excinfo.value).startswith(exception_message("Method 'file_delete' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
--- /dev/null
+import http
+import pytest
+
+from osm_common.msgbase import MsgBase, MsgException
+
+
+def exception_message(message):
+ return "messaging exception " + message
+
+@pytest.fixture
+def msg_base():
+ return MsgBase()
+
+def test_constructor():
+ msgbase = MsgBase()
+
+ assert msgbase != None
+ assert isinstance(msgbase, MsgBase)
+
+def test_connect(msg_base):
+ msg_base.connect()
+
+def test_disconnect(msg_base):
+ msg_base.disconnect()
+
+def test_write(msg_base):
+ with pytest.raises(MsgException) as excinfo:
+ msg_base.write("test", "test", "test")
+ assert str(excinfo.value).startswith(exception_message("Method 'write' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
+
+def test_read(msg_base):
+ with pytest.raises(MsgException) as excinfo:
+ msg_base.read("test")
+ assert str(excinfo.value).startswith(exception_message("Method 'read' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
+
+def test_aiowrite(msg_base, event_loop):
+ with pytest.raises(MsgException) as excinfo:
+ event_loop.run_until_complete(msg_base.aiowrite("test", "test", "test", event_loop))
+ assert str(excinfo.value).startswith(exception_message("Method 'aiowrite' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR
+
+def test_aioread(msg_base, event_loop):
+ with pytest.raises(MsgException) as excinfo:
+ event_loop.run_until_complete(msg_base.aioread("test", event_loop))
+ assert str(excinfo.value).startswith(exception_message("Method 'aioread' not implemented"))
+ assert excinfo.value.http_code == http.HTTPStatus.INTERNAL_SERVER_ERROR