From 6ea743740ff4524287e5b63a18a45bd19d2451bb Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 7 Sep 2017 21:44:16 +0200 Subject: o Reformat all. --- test/test_bom.py | 82 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 38 deletions(-) (limited to 'test/test_bom.py') diff --git a/test/test_bom.py b/test/test_bom.py index 6da7798..fd8c6c6 100644 --- a/test/test_bom.py +++ b/test/test_bom.py @@ -7,58 +7,64 @@ from ee.kicad.bom.io import read_bom basedir = os.path.dirname(os.path.abspath(__file__)) + @pytest.mark.parametrize("s, ref, val, rest", [ ("C12", "C", 12, ""), ("C12n", "C", 12, "n"), ("C", "C", sys.maxsize, ""), ("Foo", "Foo", sys.maxsize, ""), ("+3.0VA1", "+3.0VA1", sys.maxsize, ""), - ]) +]) def test_split_ref(s, ref, val, rest): - assert split_ref(s) == (ref, val, rest) + assert split_ref(s) == (ref, val, rest) + def test_read_bom_1(): - bom = read_bom(basedir + '/../demo/kicad/bom/A64-OlinuXino_Rev_C.xml') - assert len(bom.get_components()) == 425 + bom = read_bom(basedir + '/../demo/kicad/bom/A64-OlinuXino_Rev_C.xml') + assert len(bom.get_components()) == 425 + def test_read_bom_2(): - bom = read_bom(basedir + '/../demo/kicad/bom/gw.xml') - assert len(bom.get_components()) == 165 + bom = read_bom(basedir + '/../demo/kicad/bom/gw.xml') + assert len(bom.get_components()) == 165 + + r5 = bom.get_component("R5") + assert r5.ref == "R5" + assert r5.value == "R0402_100R" + assert r5["value"] == "R0402_100R" + assert r5.footprint == "Resistors_SMD:R_0402" + assert r5.library.name == "gw-cache" + assert len(r5.fields) == 4 + assert r5.fields["Part Number"] == "CRCW0402100RFKED" + assert r5["Part Number"] == "CRCW0402100RFKED" + assert set( + ['ref', 'value', 'Capacitance', 'Color', 'Description', 'Frequency', 'Impedance', 'Inductance', 'Manufacturer', + 'Part Number', 'Resistance']) == bom.all_field_names() - r5 = bom.get_component("R5") - assert r5.ref == "R5" - assert r5.value == "R0402_100R" - assert r5["value"] == "R0402_100R" - assert r5.footprint == "Resistors_SMD:R_0402" - assert r5.library.name == "gw-cache" - assert len(r5.fields) == 4 - assert r5.fields["Part Number"] == "CRCW0402100RFKED" - assert r5["Part Number"] == "CRCW0402100RFKED" - assert set(['ref', 'value', 'Capacitance', 'Color', 'Description', 'Frequency', 'Impedance', 'Inductance', 'Manufacturer', 'Part Number', 'Resistance']) == bom.all_field_names() + assert not "foo" in r5 + with pytest.raises(KeyError): + r5["foo"] - assert not "foo" in r5 - with pytest.raises(KeyError): - r5["foo"] def test_read_bom_2_pandas(): - bom = read_bom(basedir + '/../demo/kicad/bom/gw.xml').to_pandas() - assert len(bom) == 165 + bom = read_bom(basedir + '/../demo/kicad/bom/gw.xml').to_pandas() + assert len(bom) == 165 - print("bom") - print(str(bom)) - r5 = bom.loc["R5"] - print(str(r5.index)) -# assert r5.index == "R5" - assert r5["ref"] == "R5" - assert r5["value"] == "R0402_100R" - assert r5["value"] == "R0402_100R" -# assert r5["footprint"] == "Resistors_SMD:R_0402" -# assert r5.library.name == "gw-cache" -# assert len(r5.fields) == 4 -# assert r5.fields["Part Number"] == "CRCW0402100RFKED" - assert r5["Part Number"] == "CRCW0402100RFKED" -# assert set(['ref', 'value', 'Capacitance', 'Color', 'Description', 'Frequency', 'Impedance', 'Inductance', 'Manufacturer', 'Part Number', 'Resistance']) == bom.all_field_names() + print("bom") + print(str(bom)) + r5 = bom.loc["R5"] + print(str(r5.index)) + # assert r5.index == "R5" + assert r5["ref"] == "R5" + assert r5["value"] == "R0402_100R" + assert r5["value"] == "R0402_100R" + # assert r5["footprint"] == "Resistors_SMD:R_0402" + # assert r5.library.name == "gw-cache" + # assert len(r5.fields) == 4 + # assert r5.fields["Part Number"] == "CRCW0402100RFKED" + assert r5["Part Number"] == "CRCW0402100RFKED" + # assert set(['ref', 'value', 'Capacitance', 'Color', 'Description', 'Frequency', 'Impedance', 'Inductance', 'Manufacturer', 'Part Number', 'Resistance']) == bom.all_field_names() - assert not "foo" in r5 - with pytest.raises(KeyError): - r5["foo"] + assert not "foo" in r5 + with pytest.raises(KeyError): + r5["foo"] -- cgit v1.2.3