Files
cobol-java-v3/tests/config/test_program_schema_drop_tables.py

38 lines
1.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Scenario `drop_tables` 配置解析测试。
用于覆盖「表缺失导致 OPEN CURSOR 失败」的错误分支(如 SHA02MNC #5 T
EMP-OPEN SQLCODE≠0)。机制通用:任一程序可在场景里声明要 DROP 的表,
运行时 OPEN 该表即失败 → SQL 错误分支可达。
"""
import sys, os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
from config.program_schema import ProgramSchema
_YAML = """
program_id: SHA02MNC
db_type: SQLite
db_name: INSURANCEDB.db
db_tables:
- name: EMP_MASTER
columns:
- name: EMP_ID
type: CHAR(8)
primary_key: true
runs:
- id: normal
- id: emp_open_fail
drop_tables: [EMP_MASTER]
inject_duplicate_pk: false
"""
def test_drop_tables_parsed_from_yaml(tmp_path):
p = tmp_path / "SHA02MNC.yaml"
p.write_text(_YAML, encoding="utf-8")
schema = ProgramSchema.from_yaml(p)
assert len(schema.runs) == 2
fail = schema.runs[1]
assert fail.id == "emp_open_fail"
assert fail.drop_tables == ["EMP_MASTER"]