54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
# tests/test_db_parser.py
|
|
import os
|
|
from agent.input_parser import InputParser
|
|
from agent.models import ProgramMeta
|
|
|
|
FIXTURE_DIR = os.path.join(os.path.dirname(__file__), 'test_data')
|
|
|
|
|
|
def test_parse_db_definition():
|
|
parser = InputParser(
|
|
design_md_path='dummy.md', source_cbl_path='dummy.cbl',
|
|
file_db_md_path='dummy.md', cpy_dir='dummy_cpy',
|
|
db_md_path=os.path.join(FIXTURE_DIR, 'DB定義書.md')
|
|
)
|
|
|
|
meta = ProgramMeta(
|
|
program_id='TEST', program_name='テスト', system_name='',
|
|
pgm_type='メイン', pgm_pattern='DB更新',
|
|
summary_lines=[], prerequisites=[], files=[], keys=[], modules=[],
|
|
process_detail='', output_records='',
|
|
input_type='mixed',
|
|
copy_fields={}, db_tables={}
|
|
)
|
|
|
|
parser._parse_db_definition(meta)
|
|
|
|
assert len(meta.db_tables) > 0
|
|
assert 'EMP_MASTER' in meta.db_tables
|
|
|
|
emp = meta.db_tables['EMP_MASTER']
|
|
assert emp.db_id == 'EMP_MASTER'
|
|
assert len(emp.columns) >= 3
|
|
assert emp.pk_columns == ['EMP_ID']
|
|
|
|
|
|
def test_parse_db_skipped_for_file_type():
|
|
parser = InputParser(
|
|
design_md_path='dummy.md', source_cbl_path='dummy.cbl',
|
|
file_db_md_path='dummy.md', cpy_dir='dummy_cpy',
|
|
db_md_path=os.path.join(FIXTURE_DIR, 'DB定義書.md')
|
|
)
|
|
|
|
meta = ProgramMeta(
|
|
program_id='TEST', program_name='テスト', system_name='',
|
|
pgm_type='メイン', pgm_pattern='マッチング(1:1)',
|
|
summary_lines=[], prerequisites=[], files=[], keys=[], modules=[],
|
|
process_detail='', output_records='',
|
|
input_type='file',
|
|
copy_fields={}, db_tables={}
|
|
)
|
|
|
|
parser._parse_db_definition(meta)
|
|
assert len(meta.db_tables) == 0
|