aboutsummaryrefslogtreecommitdiff
path: root/test/test_sch.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_sch.py')
-rw-r--r--test/test_sch.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test_sch.py b/test/test_sch.py
new file mode 100644
index 0000000..a3c6915
--- /dev/null
+++ b/test/test_sch.py
@@ -0,0 +1,34 @@
+import pytest
+import sys
+import os.path
+from ee.kicad import read_schematic
+
+basedir = os.path.dirname(os.path.abspath(__file__))
+
+def dump_schema(sch):
+ print("Libraries")
+ for l in sch.libraries:
+ print("name: {}".format(l.name))
+
+ print("Components")
+ for c in sch.components:
+ if c.unit != 1:
+ continue
+ print("REF: {}, fields={}".format(c.ref if c.unit == 1 else "{}/{}".format(c.ref, c.unit), len(c.fields)))
+ for f in c.fields:
+ print(" {}={}".format(f.name, f.value))
+
+def load(path):
+ p = basedir + "/parser/" + path
+ print("p={}".format(p))
+ return read_schematic(p)
+
+def test_demo_1():
+ sch = load("parser-demo-1.sch")
+ dump_schema(sch)
+ r101 = sch.get_component("R101")
+ assert r101
+
+def test_sch():
+ sch = load("foo.sch")
+ dump_schema(sch)