Added test for "datasheet_as_link"
This commit is contained in:
parent
ca67cc8ac3
commit
570553b616
|
|
@ -0,0 +1,95 @@
|
|||
EESchema Schematic File Version 4
|
||||
EELAYER 30 0
|
||||
EELAYER END
|
||||
$Descr A4 11693 8268
|
||||
encoding utf-8
|
||||
Sheet 1 1
|
||||
Title "KiBom Test Schematic"
|
||||
Date "2020-03-12"
|
||||
Rev "A"
|
||||
Comp "https://github.com/SchrodingersGat/KiBom"
|
||||
Comment1 ""
|
||||
Comment2 ""
|
||||
Comment3 ""
|
||||
Comment4 ""
|
||||
$EndDescr
|
||||
Text Notes 550 950 0 50 ~ 0
|
||||
This schematic serves as a test-file for the KiBom export script.\n\nAfter making a change to the schematic, remember to re-export the BOM to generate the intermediate .xml file\n\n(The testing framework cannot perform the netlist-export step!)
|
||||
$Comp
|
||||
L Connector:Conn_01x02_Male J1
|
||||
U 1 1 5F10E435
|
||||
P 2850 2300
|
||||
F 0 "J1" H 2750 2200 50 0000 C CNN
|
||||
F 1 "Molex KK" H 2850 2100 50 0000 C CNN
|
||||
F 2 "" H 2850 2300 50 0001 C CNN
|
||||
F 3 "https://www.molex.com/webdocs/datasheets/pdf/en-us//0022232021_PCB_HEADERS.pdf" H 2850 2300 50 0001 C CNN
|
||||
F 4 "900-0022232021-ND" H 2850 2300 50 0001 C CNN "digikey#"
|
||||
F 5 "0022232021" H 2850 2300 50 0001 C CNN "manf#"
|
||||
1 2850 2300
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Connector:Conn_01x02_Male J2
|
||||
U 1 1 5F10E81F
|
||||
P 4500 2300
|
||||
F 0 "J2" H 4450 2200 50 0000 R CNN
|
||||
F 1 "Molex KK" H 4700 2100 50 0000 R CNN
|
||||
F 2 "" H 4500 2300 50 0001 C CNN
|
||||
F 3 "https://www.molex.com/webdocs/datasheets/pdf/en-us//0022232021_PCB_HEADERS.pdf" H 4500 2300 50 0001 C CNN
|
||||
F 4 "900-0022232021-ND" H 4500 2300 50 0001 C CNN "digikey#"
|
||||
F 5 "0022232021" H 4500 2300 50 0001 C CNN "manf#"
|
||||
1 4500 2300
|
||||
-1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R1
|
||||
U 1 1 5F10F746
|
||||
P 3450 2300
|
||||
F 0 "R1" V 3350 2300 50 0000 C CNN
|
||||
F 1 "1k" V 3450 2300 50 0000 C CNN
|
||||
F 2 "" V 3380 2300 50 0001 C CNN
|
||||
F 3 "https://www.bourns.com/docs/product-datasheets/CRxxxxx.pdf" H 3450 2300 50 0001 C CNN
|
||||
F 4 "CR0805-JW-102ELFCT-ND" V 3450 2300 50 0001 C CNN "digikey#"
|
||||
F 5 "CR0805-JW-102ELF" V 3450 2300 50 0001 C CNN "manf#"
|
||||
1 3450 2300
|
||||
0 1 1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C1
|
||||
U 1 1 5F10F92F
|
||||
P 3750 2500
|
||||
F 0 "C1" H 3865 2546 50 0000 L CNN
|
||||
F 1 "1nF" H 3865 2455 50 0000 L CNN
|
||||
F 2 "" H 3788 2350 50 0001 C CNN
|
||||
F 3 "https://content.kemet.com/datasheets/KEM_C1002_X7R_SMD.pdf" H 3750 2500 50 0001 C CNN
|
||||
F 4 "399-1147-1-ND" H 3750 2500 50 0001 C CNN "digikey#"
|
||||
F 5 "C0805C102K5RACTU" H 3750 2500 50 0001 C CNN "manf#"
|
||||
F 6 "DNF" H 3750 2500 50 0001 C CNN "Config"
|
||||
1 3750 2500
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
3050 2300 3300 2300
|
||||
Wire Wire Line
|
||||
3600 2300 3750 2300
|
||||
Wire Wire Line
|
||||
3750 2350 3750 2300
|
||||
Connection ~ 3750 2300
|
||||
Wire Wire Line
|
||||
3750 2300 4300 2300
|
||||
Wire Wire Line
|
||||
3050 2400 3200 2400
|
||||
Wire Wire Line
|
||||
3200 2400 3200 2750
|
||||
Wire Wire Line
|
||||
3200 2750 3750 2750
|
||||
Wire Wire Line
|
||||
3750 2750 3750 2650
|
||||
Wire Wire Line
|
||||
3750 2750 4150 2750
|
||||
Wire Wire Line
|
||||
4150 2750 4150 2400
|
||||
Wire Wire Line
|
||||
4150 2400 4300 2400
|
||||
Connection ~ 3750 2750
|
||||
$EndSCHEMATC
|
||||
|
|
@ -146,10 +146,13 @@ def test_int_bom_simple_xlsx():
|
|||
ctx.clean_up()
|
||||
|
||||
|
||||
def get_components(rows, col):
|
||||
def get_column(rows, col, split=True):
|
||||
components = []
|
||||
for r in rows:
|
||||
components.extend(r[col].split())
|
||||
if split:
|
||||
components.extend(r[col].split())
|
||||
else:
|
||||
components.append(r[col])
|
||||
return components
|
||||
|
||||
|
||||
|
|
@ -165,5 +168,35 @@ def test_int_bom_sort_1():
|
|||
'R5', 'R4', 'R9', 'R10', 'R3', 'R2', 'R1', 'R8', 'R7']
|
||||
check_kibom_test_netlist(rows, ref_column, 14, None, exp)
|
||||
# Check the sorting
|
||||
assert get_components(rows, ref_column) == exp
|
||||
assert get_column(rows, ref_column) == exp
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_int_bom_datasheet_link():
|
||||
prj = 'links'
|
||||
ext = 'html'
|
||||
ctx = context.TestContext('test_int_bom_datasheet_link', prj, 'int_bom_datasheet_link', BOM_DIR)
|
||||
ctx.run(no_board_file=True, extra=['-e', os.path.join(ctx.get_board_dir(), prj+'.sch')])
|
||||
out = prj + '.' + ext
|
||||
rows, headers = ctx.load_html(out)
|
||||
# Test we got the normal and DNF tables
|
||||
assert len(rows) == 2
|
||||
assert len(headers) == 2
|
||||
# Test both tables has the same headings and they are the expected
|
||||
assert headers[0] == headers[1]
|
||||
head_no_comp = deepcopy(KIBOM_TEST_HEAD)
|
||||
assert headers[0] == ['', 'References', 'Part', 'Value', 'Quantity Per PCB', 'digikey#', 'manf#']
|
||||
# Look for reference and quantity columns
|
||||
ref_column = headers[0].index(REF_COLUMN_NAME)
|
||||
part_column = headers[0].index('Part')
|
||||
# Check the normal table
|
||||
check_kibom_test_netlist(rows[0], ref_column, 2, ['C1'], ['J1', 'J2','R1'])
|
||||
# Check the DNF table
|
||||
check_kibom_test_netlist(rows[1], ref_column, 1, ['J1', 'J2','R1'], ['C1'])
|
||||
# Check the datasheet link
|
||||
parts = get_column(rows[0]+rows[1], part_column, False)
|
||||
for c in parts:
|
||||
assert c.strip().startswith('<a href')
|
||||
assert 'pdf' in c
|
||||
logging.debug(c + ' OK')
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
# Example KiPlot config file
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: 'bom_internal'
|
||||
comment: "Bill of Materials in HTML format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
format: HTML
|
||||
datasheet_as_link: 'Part'
|
||||
output: '%f.%x'
|
||||
columns:
|
||||
- References
|
||||
- Part
|
||||
- Value
|
||||
- Quantity Per PCB
|
||||
- digikey#
|
||||
- manf#
|
||||
Loading…
Reference in New Issue