aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-08-13 11:22:07 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-08-13 11:22:07 +0200
commitc895e6c051cfda77a22b31367cf5c0bbedce4249 (patch)
treeeaaa475114cec384bc4d3d8e59da4e1ae10b3eb4 /test
parent21ed642fa528cc732f8d682266111be64c1ae711 (diff)
downloadee-python-c895e6c051cfda77a22b31367cf5c0bbedce4249.tar.gz
ee-python-c895e6c051cfda77a22b31367cf5c0bbedce4249.tar.bz2
ee-python-c895e6c051cfda77a22b31367cf5c0bbedce4249.tar.xz
ee-python-c895e6c051cfda77a22b31367cf5c0bbedce4249.zip
o Going more jupyter.
Diffstat (limited to 'test')
-rw-r--r--test/test_bom.py41
-rw-r--r--test/test_digikey.py16
2 files changed, 57 insertions, 0 deletions
diff --git a/test/test_bom.py b/test/test_bom.py
index 1a54a9e..6da7798 100644
--- a/test/test_bom.py
+++ b/test/test_bom.py
@@ -1,11 +1,22 @@
import pytest
import os.path
+import sys
from ee.kicad.bom import *
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)
+
def test_read_bom_1():
bom = read_bom(basedir + '/../demo/kicad/bom/A64-OlinuXino_Rev_C.xml')
assert len(bom.get_components()) == 425
@@ -17,7 +28,37 @@ def test_read_bom_2():
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"]
+
+def test_read_bom_2_pandas():
+ 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()
+
+ assert not "foo" in r5
+ with pytest.raises(KeyError):
+ r5["foo"]
diff --git a/test/test_digikey.py b/test/test_digikey.py
new file mode 100644
index 0000000..148f56e
--- /dev/null
+++ b/test/test_digikey.py
@@ -0,0 +1,16 @@
+from ee.kicad.bom import *
+from ee.kicad.bom.io import read_bom
+import ee.kicad.bom_tool as bom_tool
+import ee.kicad.bom_tool.predef as predef
+import os.path
+import pytest
+
+basedir = os.path.dirname(os.path.abspath(__file__))
+
+@pytest.mark.skip(reason="disabled for now")
+def test_digikey():
+ print("")
+ bom = read_bom(basedir + '/../demo/kicad/bom/A64-OlinuXino_Rev_C.xml')
+ settings = bom_tool.Settings(suppliers = [predef.digikey])
+ pd = bom_tool.to_panda(bom, settings, predef.digikeyCsvFormat(predef.digikey))
+ print(pd.to_csv(index = False))