aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-09-07 21:44:16 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-09-07 21:44:16 +0200
commit6ea743740ff4524287e5b63a18a45bd19d2451bb (patch)
treed14ec9c5b580450b8e2db2b115be85aea48afc42 /test
parenta3da99e22540c026e4acf7bdc735aa221a4dd752 (diff)
downloadee-python-6ea743740ff4524287e5b63a18a45bd19d2451bb.tar.gz
ee-python-6ea743740ff4524287e5b63a18a45bd19d2451bb.tar.bz2
ee-python-6ea743740ff4524287e5b63a18a45bd19d2451bb.tar.xz
ee-python-6ea743740ff4524287e5b63a18a45bd19d2451bb.zip
o Reformat all.
Diffstat (limited to 'test')
-rw-r--r--test/test_bom.py82
-rw-r--r--test/test_digikey.py26
-rw-r--r--test/test_formatting.py24
3 files changed, 71 insertions, 61 deletions
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"]
diff --git a/test/test_digikey.py b/test/test_digikey.py
index 0b79777..6073e25 100644
--- a/test/test_digikey.py
+++ b/test/test_digikey.py
@@ -10,19 +10,19 @@ client = dk.DigikeyClient(digikey)
def test_digikey_1():
- p = client.search("TCR2LF18LM(CTTR-ND")
- assert isinstance(p, dk.DigikeyProduct)
- assert p.part_number == "TCR2LF18LM(CTTR-ND"
- assert len(p.attributes) > 5
- x = p.to_yaml()
- print(type(x))
- print("{}".format(x))
- yaml.dump(x, sys.stdout)
+ p = client.search("TCR2LF18LM(CTTR-ND")
+ assert isinstance(p, dk.DigikeyProduct)
+ assert p.part_number == "TCR2LF18LM(CTTR-ND"
+ assert len(p.attributes) > 5
+ x = p.to_yaml()
+ print(type(x))
+ print("{}".format(x))
+ yaml.dump(x, sys.stdout)
def test_digikey_2():
- response = client.search("TCR2LF")
- [print(p.part_id) for p in response.products]
- assert len(response.products) == 28
- # p = products[0]
- # assert p.part_number == "TCR2LF18LM(CTTR-ND"
+ response = client.search("TCR2LF")
+ [print(p.part_id) for p in response.products]
+ assert len(response.products) == 28
+ # p = products[0]
+ # assert p.part_number == "TCR2LF18LM(CTTR-ND"
diff --git a/test/test_formatting.py b/test/test_formatting.py
index 6fa0b07..18f582c 100644
--- a/test/test_formatting.py
+++ b/test/test_formatting.py
@@ -2,6 +2,7 @@ import pytest
import numpy as np
from ee.formatting import eng_str
+
@pytest.mark.parametrize("input,expected", [
(0, "0"),
(5.5, "5.5"),
@@ -18,29 +19,32 @@ from ee.formatting import eng_str
(0.000055, "55 u"),
(0.0000055, "5.5 u"),
(0.00000055, "550 p"),
- ])
+])
def test_eng_str(input, expected):
- assert expected == eng_str(input)
- npinput = np.float64(input)
- assert expected == eng_str(npinput)
+ assert expected == eng_str(input)
+ npinput = np.float64(input)
+ assert expected == eng_str(npinput)
+
@pytest.mark.parametrize("input,expected", [
(0, "0 A"),
(5.5, "5.5 A"),
(1100, "1.1 kA"),
(0.05, "50 mA"),
- ])
+])
def test_eng_str_with_unit(input, expected):
- assert expected == eng_str(input, unit = 'A')
+ assert expected == eng_str(input, unit='A')
+
@pytest.mark.parametrize("input,expected", [
(100, ''), (101, ''), (102, ''), (103, ''), (104, ''), (105, ''), (106, ''), (107, ''), (108, ''), (109, ''),
(110, ''), (111, ''), (112, ''), (113, ''), (114, ''), (115, ''), (116, ''), (117, ''), (118, ''), (119, ''),
(120, ''), (121, ''), (122, ''), (123, ''), (124, ''), (125, ''), (126, ''), (127, ''), (128, ''), (129, ''),
(130, ''), (131, ''), (132, ''), (133, ''), (134, ''), (135, ''), (136, ''), (137, ''), (138, ''), (139, ''),
- ])
+])
def xx_test_eng_str2(input, expected):
- assert expected == eng_str(input)
+ assert expected == eng_str(input)
+
@pytest.mark.parametrize("input,expected", [
(10, '10'),
@@ -53,6 +57,6 @@ def xx_test_eng_str2(input, expected):
(17, '17'),
(18, '18'),
(19, '19'),
- ])
+])
def xx_test_eng_str3(input, expected):
- assert expected == eng_str(input)
+ assert expected == eng_str(input)