From 20a6b126423b4ef97dcdb04cc53672712c6f5723 Mon Sep 17 00:00:00 2001 From: Jonas Zeunert Date: Sat, 27 Apr 2024 14:21:55 +0200 Subject: [PATCH] Add: Parser + test --- pdm.lock | 60 +++++++++++++++++++- pyproject.toml | 3 + src/ergogen_footprint_converter/converter.py | 9 ++- tests/integration/test_converter.py | 38 ------------- 4 files changed, 69 insertions(+), 41 deletions(-) delete mode 100644 tests/integration/test_converter.py diff --git a/pdm.lock b/pdm.lock index fd57fed..27b46a2 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "test", "dev"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.1" -content_hash = "sha256:253ddec953150d944f40ed508f2472dad64d4691281c7a8741683c5fd8c5ccba" +content_hash = "sha256:007db48b3ef077fcedf2de70b1d3f8d3cc0e26f145fbb40868b84d4847717834" [[package]] name = "argparse" @@ -74,6 +74,17 @@ files = [ {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, ] +[[package]] +name = "kiutils" +version = "1.4.8" +requires_python = ">=3.7" +summary = "Simple and SCM-friendly KiCad file parser for KiCad 6.0 and up" +groups = ["default"] +files = [ + {file = "kiutils-1.4.8-py3-none-any.whl", hash = "sha256:ca7c5c7eafb7bc33daa3d6cfe42cc704be2bcd2206103b28ad2682d88a6072ae"}, + {file = "kiutils-1.4.8.tar.gz", hash = "sha256:18c5803283e579cfe8772955e7702548d7139e0fc630daa579ed6b2b767db846"}, +] + [[package]] name = "mccabe" version = "0.7.0" @@ -85,6 +96,42 @@ files = [ {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, ] +[[package]] +name = "mypy" +version = "1.10.0" +requires_python = ">=3.8" +summary = "Optional static typing for Python" +groups = ["default"] +dependencies = [ + "mypy-extensions>=1.0.0", + "typing-extensions>=4.1.0", +] +files = [ + {file = "mypy-1.10.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3be66771aa5c97602f382230165b856c231d1277c511c9a8dd058be4784472e1"}, + {file = "mypy-1.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8b2cbaca148d0754a54d44121b5825ae71868c7592a53b7292eeb0f3fdae95ee"}, + {file = "mypy-1.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1ec404a7cbe9fc0e92cb0e67f55ce0c025014e26d33e54d9e506a0f2d07fe5de"}, + {file = "mypy-1.10.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e22e1527dc3d4aa94311d246b59e47f6455b8729f4968765ac1eacf9a4760bc7"}, + {file = "mypy-1.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:a87dbfa85971e8d59c9cc1fcf534efe664d8949e4c0b6b44e8ca548e746a8d53"}, + {file = "mypy-1.10.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:a781f6ad4bab20eef8b65174a57e5203f4be627b46291f4589879bf4e257b97b"}, + {file = "mypy-1.10.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b808e12113505b97d9023b0b5e0c0705a90571c6feefc6f215c1df9381256e30"}, + {file = "mypy-1.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f55583b12156c399dce2df7d16f8a5095291354f1e839c252ec6c0611e86e2e"}, + {file = "mypy-1.10.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:4cf18f9d0efa1b16478c4c129eabec36148032575391095f73cae2e722fcf9d5"}, + {file = "mypy-1.10.0-cp312-cp312-win_amd64.whl", hash = "sha256:bc6ac273b23c6b82da3bb25f4136c4fd42665f17f2cd850771cb600bdd2ebeda"}, + {file = "mypy-1.10.0-py3-none-any.whl", hash = "sha256:f8c083976eb530019175aabadb60921e73b4f45736760826aa1689dda8208aee"}, + {file = "mypy-1.10.0.tar.gz", hash = "sha256:3d087fcbec056c4ee34974da493a826ce316947485cef3901f511848e687c131"}, +] + +[[package]] +name = "mypy-extensions" +version = "1.0.0" +requires_python = ">=3.5" +summary = "Type system extensions for programs checked with the mypy type checker." +groups = ["default"] +files = [ + {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, + {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, +] + [[package]] name = "packaging" version = "24.0" @@ -176,3 +223,14 @@ files = [ {file = "tomlkit-0.12.4-py3-none-any.whl", hash = "sha256:5cd82d48a3dd89dee1f9d64420aa20ae65cfbd00668d6f094d7578a78efbb77b"}, {file = "tomlkit-0.12.4.tar.gz", hash = "sha256:7ca1cfc12232806517a8515047ba66a19369e71edf2439d0f5824f91032b6cc3"}, ] + +[[package]] +name = "typing-extensions" +version = "4.11.0" +requires_python = ">=3.8" +summary = "Backported and Experimental Type Hints for Python 3.8+" +groups = ["default"] +files = [ + {file = "typing_extensions-4.11.0-py3-none-any.whl", hash = "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a"}, + {file = "typing_extensions-4.11.0.tar.gz", hash = "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0"}, +] diff --git a/pyproject.toml b/pyproject.toml index 57aa980..ce466e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,8 @@ dependencies = [ "argparse", "pathlib", "pytest>=8.1.1", + "mypy>=1.10.0", + "kiutils>=1.4.8", ] license = {text = "GPL"} @@ -53,6 +55,7 @@ addopts = "-ra -q" testpaths = [ "tests", "tests/integration", + "tests/unit", ] pythonpath = './src' diff --git a/src/ergogen_footprint_converter/converter.py b/src/ergogen_footprint_converter/converter.py index 21a52c6..156169e 100644 --- a/src/ergogen_footprint_converter/converter.py +++ b/src/ergogen_footprint_converter/converter.py @@ -1,3 +1,8 @@ class Converter: - def __init__(self): - None + input = "" + + def __init__(self, input: str): + self.input = input + + def convert(self) -> str: + return "" diff --git a/tests/integration/test_converter.py b/tests/integration/test_converter.py deleted file mode 100644 index 1f4ca3c..0000000 --- a/tests/integration/test_converter.py +++ /dev/null @@ -1,38 +0,0 @@ -from pytest import fixture -import ergogen_footprint_converter.main as main - - -@fixture -def out_dir (tmp_path): - out_dir = tmp_path / "out" - out_dir.mkdir() - return out_dir - -@fixture -def in_name (): - return "promicro.kicad_mod" - -@fixture -def call_main (in_name, out_dir): - args = { - "in": "tests/integration/data/simple/" + in_name, - "out": out_dir - } - - main.main(args) - - return out_dir / (in_name.split('.')[0] + ".js") - - -def test_exists(call_main): - out = call_main - - assert out.exists() - -def test_simple(call_main): - out = call_main - - expected = open("tests/integration/data/simple/promicro.js").readlines() - - assert out.read_text() == expected -