v1.0
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
# tests/test_input_parser.py
|
||||
import os
|
||||
from agent.input_parser import InputParser
|
||||
|
||||
FIXTURE_DIR = os.path.join(os.path.dirname(__file__), 'test_data')
|
||||
|
||||
|
||||
def test_parse_design_basic_info():
|
||||
parser = InputParser(
|
||||
design_md_path=os.path.join(FIXTURE_DIR, '詳細設計書_ZAN04MAT.md'),
|
||||
source_cbl_path='dummy.cbl',
|
||||
file_db_md_path='dummy.md',
|
||||
cpy_dir='dummy_cpy',
|
||||
db_md_path='dummy_db.md'
|
||||
)
|
||||
parser._design_text = parser._read_file(parser.design_md_path)
|
||||
|
||||
from agent.models import ProgramMeta
|
||||
meta = ProgramMeta(program_id='', program_name='', system_name='',
|
||||
pgm_type='', pgm_pattern='',
|
||||
summary_lines=[], prerequisites=[],
|
||||
files=[], keys=[], modules=[],
|
||||
process_detail='', output_records='',
|
||||
input_type='file', copy_fields={}, db_tables={})
|
||||
|
||||
parser._parse_basic_info(meta)
|
||||
assert meta.program_id == 'ZAN04MAT'
|
||||
assert meta.pgm_pattern == 'マッチング(1:1)'
|
||||
assert meta.pgm_type == 'メイン'
|
||||
assert '残業統計管理システム' in meta.system_name
|
||||
|
||||
|
||||
def test_parse_use_files():
|
||||
parser = InputParser(
|
||||
design_md_path=os.path.join(FIXTURE_DIR, '詳細設計書_ZAN04MAT.md'),
|
||||
source_cbl_path='dummy.cbl', file_db_md_path='dummy.md',
|
||||
cpy_dir='dummy_cpy', db_md_path='dummy_db.md'
|
||||
)
|
||||
parser._design_text = parser._read_file(parser.design_md_path)
|
||||
|
||||
from agent.models import ProgramMeta
|
||||
meta = ProgramMeta(program_id='', program_name='', system_name='',
|
||||
pgm_type='', pgm_pattern='',
|
||||
summary_lines=[], prerequisites=[],
|
||||
files=[], keys=[], modules=[],
|
||||
process_detail='', output_records='',
|
||||
input_type='file', copy_fields={}, db_tables={})
|
||||
|
||||
parser._parse_use_files(meta)
|
||||
assert len(meta.files) == 5
|
||||
r01 = [f for f in meta.files if f.identifier == 'R01'][0]
|
||||
assert r01.file_db_name == 'OVT-SORTED'
|
||||
assert r01.copy_group == 'ZAN01REC'
|
||||
assert r01.medium == 'PS'
|
||||
assert r01.io == 'I'
|
||||
|
||||
|
||||
def test_determine_input_type_file():
|
||||
parser = InputParser(
|
||||
design_md_path=os.path.join(FIXTURE_DIR, '詳細設計書_ZAN04MAT.md'),
|
||||
source_cbl_path='dummy.cbl', file_db_md_path='dummy.md',
|
||||
cpy_dir='dummy_cpy', db_md_path='dummy_db.md'
|
||||
)
|
||||
|
||||
from agent.models import ProgramMeta, FileInfo
|
||||
meta = ProgramMeta(program_id='ZAN04MAT', program_name='', system_name='',
|
||||
pgm_type='', pgm_pattern='',
|
||||
summary_lines=[], prerequisites=[],
|
||||
files=[], keys=[], modules=[],
|
||||
process_detail='', output_records='',
|
||||
input_type='file', copy_fields={}, db_tables={})
|
||||
meta.files = [
|
||||
FileInfo(no=1, file_db_name='F1', identifier='R01', dd_name='DD1',
|
||||
io='I', copy_group='C1', format='FB', record_len=80,
|
||||
medium='PS', remarks=''),
|
||||
FileInfo(no=2, file_db_name='F2', identifier='W01', dd_name='DD2',
|
||||
io='O', copy_group='C2', format='FB', record_len=80,
|
||||
medium='PS', remarks=''),
|
||||
]
|
||||
parser._determine_input_type(meta)
|
||||
assert meta.input_type == 'file'
|
||||
|
||||
|
||||
def test_determine_input_type_mixed():
|
||||
parser = InputParser(
|
||||
design_md_path=os.path.join(FIXTURE_DIR, '詳細設計書_ZAN04MAT.md'),
|
||||
source_cbl_path='dummy.cbl', file_db_md_path='dummy.md',
|
||||
cpy_dir='dummy_cpy', db_md_path='dummy_db.md'
|
||||
)
|
||||
|
||||
from agent.models import ProgramMeta, FileInfo
|
||||
meta = ProgramMeta(program_id='TEST', program_name='', system_name='',
|
||||
pgm_type='', pgm_pattern='',
|
||||
summary_lines=[], prerequisites=[],
|
||||
files=[], keys=[], modules=[],
|
||||
process_detail='', output_records='',
|
||||
input_type='file', copy_fields={}, db_tables={})
|
||||
meta.files = [
|
||||
FileInfo(no=1, file_db_name='F1', identifier='R01', dd_name='DD1',
|
||||
io='I', copy_group='C1', format='FB', record_len=80,
|
||||
medium='PS', remarks=''),
|
||||
FileInfo(no=2, file_db_name='DB1', identifier='DB', dd_name='',
|
||||
io='I', copy_group='', format='', record_len=0,
|
||||
medium='DB', remarks=''),
|
||||
]
|
||||
parser._determine_input_type(meta)
|
||||
assert meta.input_type == 'mixed'
|
||||
|
||||
|
||||
def test_parse_process_detail():
|
||||
parser = InputParser(
|
||||
design_md_path=os.path.join(FIXTURE_DIR, '詳細設計書_ZAN04MAT.md'),
|
||||
source_cbl_path='dummy.cbl', file_db_md_path='dummy.md',
|
||||
cpy_dir='dummy_cpy', db_md_path='dummy_db.md'
|
||||
)
|
||||
parser._design_text = parser._read_file(parser.design_md_path)
|
||||
|
||||
from agent.models import ProgramMeta
|
||||
meta = ProgramMeta(program_id='', program_name='', system_name='',
|
||||
pgm_type='', pgm_pattern='',
|
||||
summary_lines=[], prerequisites=[],
|
||||
files=[], keys=[], modules=[],
|
||||
process_detail='', output_records='',
|
||||
input_type='file', copy_fields={}, db_tables={})
|
||||
|
||||
parser._parse_process_detail(meta)
|
||||
assert '1000ITTSOR' in meta.process_detail
|
||||
assert 'マッチの場合' in meta.process_detail
|
||||
|
||||
|
||||
def test_parse_output_records():
|
||||
parser = InputParser(
|
||||
design_md_path=os.path.join(FIXTURE_DIR, '詳細設計書_ZAN04MAT.md'),
|
||||
source_cbl_path='dummy.cbl', file_db_md_path='dummy.md',
|
||||
cpy_dir='dummy_cpy', db_md_path='dummy_db.md'
|
||||
)
|
||||
parser._design_text = parser._read_file(parser.design_md_path)
|
||||
|
||||
from agent.models import ProgramMeta
|
||||
meta = ProgramMeta(program_id='', program_name='', system_name='',
|
||||
pgm_type='', pgm_pattern='',
|
||||
summary_lines=[], prerequisites=[],
|
||||
files=[], keys=[], modules=[],
|
||||
process_detail='', output_records='',
|
||||
input_type='file', copy_fields={}, db_tables={})
|
||||
|
||||
parser._parse_output_records(meta)
|
||||
assert 'OVT-MATCHED' in meta.output_records
|
||||
assert 'OVT-DBCLEAN' in meta.output_records
|
||||
Reference in New Issue
Block a user