Skip to content

Commit

Permalink
[Tests][BoM][Added] HRTXT simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed Jan 23, 2024
1 parent edccb13 commit 0665cea
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_plot/test_int_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
15 changes: 15 additions & 0 deletions tests/utils/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,21 @@ def load_csv(self, filename, delimiter=','):
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:
Expand Down
12 changes: 12 additions & 0 deletions tests/yaml_samples/int_bom_simple_hrtxt.kibot.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0665cea

Please sign in to comment.