[Tests][BoM][Added] HRTXT simple test

This commit is contained in:
Salvador E. Tropea 2024-01-23 10:49:12 -03:00
parent edccb13b5e
commit 0665cea3ff
3 changed files with 36 additions and 0 deletions

View File

@ -288,6 +288,15 @@ def test_int_bom_simple_csv(test_dir):
ctx.clean_up()
def test_int_bom_simple_hrtxt(test_dir):
ctx, out = kibom_setup(test_dir, 'int_bom_simple_hrtxt', ext='txt')
ctx.expect_out_file(out, sub=True)
rows, header, info = ctx.load_hrtxt(out)
check_csv_info(info, KIBOM_PRJ_INFO, KIBOM_STATS)
kibom_verif(rows, header)
ctx.clean_up()
def test_int_bom_csv_no_info(test_dir):
""" No PCB info """
ctx, out = kibom_setup(test_dir, 'int_bom_csv_no_info')

View File

@ -690,6 +690,21 @@ class TestContext(object):
info.append(r)
return rows, header, info
def load_hrtxt(self, filename):
nm = self.expect_out_file(os.path.join(self.sub_dir, filename))
nm_csv = nm.replace('.txt', '.csv')
with open(nm) as f:
with open(nm_csv, 'wt') as d:
for ln in f:
if ln.startswith('I---'):
continue
if ln[0] == 'I':
ln = ln[1:-2]
ln = ln.strip()
d.write(','.join(re.split(r'\s*I', ln)))
d.write('\n')
return self.load_csv(filename.replace('.txt', '.csv'))
def load_html(self, filename):
file = self.expect_out_file(os.path.join(self.sub_dir, filename))
with open(file) as f:

View File

@ -0,0 +1,12 @@
# Example KiBot config file
kibot:
version: 1
outputs:
- name: 'bom_internal'
comment: "Bill of Materials in Human Readable Text format"
type: bom
dir: BoM
options:
group_fields: ['Part', 'Part Lib', 'Value', 'Footprint', 'Footprint Lib']
format: HRTXT