Squashed 'paste-framework/' content from commit 34e8684
git-subtree-dir: paste-framework git-subtree-split: 34e8684c4bc3cebbe177509f42ab4ef5b5425a7a
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
数据库连接集成测试。
|
||||
需要真实数据库连接,默认被跳过。
|
||||
运行方式:pytest tests/integration/ -v
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from paste.db.basetable import BaseTable
|
||||
from paste.db.baseadapter import BaseAdapter
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
class TestDbConnection:
|
||||
"""数据库连接基础测试"""
|
||||
|
||||
@pytest.mark.skip(reason="需要真实数据库连接")
|
||||
@pytest.mark.asyncio
|
||||
async def test_ping_database(self):
|
||||
"""测试数据库连通性"""
|
||||
result = BaseAdapter.ping()
|
||||
assert result is True
|
||||
|
||||
@pytest.mark.skip(reason="需要真实数据库连接")
|
||||
@pytest.mark.asyncio
|
||||
async def test_tables_in_db(self):
|
||||
"""测试获取表列表"""
|
||||
tables = await BaseTable.tables_in_db()
|
||||
assert isinstance(tables, list)
|
||||
# 验证返回的表名称都是字符串
|
||||
for table in tables:
|
||||
assert isinstance(table, str)
|
||||
|
||||
@pytest.mark.skip(reason="需要真实数据库连接")
|
||||
@pytest.mark.asyncio
|
||||
async def test_is_table_exist(self):
|
||||
"""测试表存在性判断"""
|
||||
# 测试存在的表(information_schema.tables 必然存在)
|
||||
exists = await BaseTable.is_table_exist('information_schema')
|
||||
assert isinstance(exists, bool)
|
||||
Reference in New Issue
Block a user