Add: Test for filenotfounderror
This commit is contained in:
9
src/ergogen_footprint_converter/parser.py
Normal file
9
src/ergogen_footprint_converter/parser.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from kiutils.footprint import Footprint
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
class Parser():
|
||||||
|
footprint: Footprint
|
||||||
|
|
||||||
|
def __init__(self, input_file: Path):
|
||||||
|
self.footprint = Footprint.from_file(input_file.absolute().__str__())
|
||||||
|
|
||||||
0
tests/integration/__init__.py
Normal file
0
tests/integration/__init__.py
Normal file
42
tests/integration/test_ergogen_footprint_converter.py
Normal file
42
tests/integration/test_ergogen_footprint_converter.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
from pytest import fixture
|
||||||
|
import pytest
|
||||||
|
import ergogen_footprint_converter.main as main
|
||||||
|
|
||||||
|
res_path = "tests/integration/data/simple/"
|
||||||
|
in_name = "promicro.kicad_mod"
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
def out_dir (tmp_path):
|
||||||
|
out_dir = tmp_path / "out"
|
||||||
|
out_dir.mkdir()
|
||||||
|
return out_dir
|
||||||
|
|
||||||
|
|
||||||
|
def call_main (in_file, out_dir):
|
||||||
|
args = {
|
||||||
|
"in": res_path + in_file,
|
||||||
|
"out": out_dir
|
||||||
|
}
|
||||||
|
|
||||||
|
main.main(args)
|
||||||
|
|
||||||
|
return out_dir / (in_name.split('.')[0] + ".js")
|
||||||
|
|
||||||
|
|
||||||
|
def test_not_exists(out_dir):
|
||||||
|
with pytest.raises(FileNotFoundError):
|
||||||
|
call_main("nop", out_dir)
|
||||||
|
|
||||||
|
|
||||||
|
def test_exists(out_dir):
|
||||||
|
out = call_main(in_name, out_dir)
|
||||||
|
|
||||||
|
assert out.exists()
|
||||||
|
|
||||||
|
def test_simple(out_dir):
|
||||||
|
out = call_main(in_name, out_dir)
|
||||||
|
|
||||||
|
expected = open("tests/integration/data/simple/promicro.js").readlines()
|
||||||
|
|
||||||
|
assert out.read_text() == expected
|
||||||
|
|
||||||
0
tests/unit/__init__.py
Normal file
0
tests/unit/__init__.py
Normal file
8
tests/unit/test_converter.py
Normal file
8
tests/unit/test_converter.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from ergogen_footprint_converter.converter import Converter
|
||||||
|
|
||||||
|
def test_convert():
|
||||||
|
input = ""
|
||||||
|
converter = Converter(input)
|
||||||
|
res = converter.convert()
|
||||||
|
|
||||||
|
|
||||||
4
tests/unit/test_parser.py
Normal file
4
tests/unit/test_parser.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
from ergogen_footprint_converter.parser import Parser
|
||||||
|
|
||||||
|
def test_parser():
|
||||||
|
None
|
||||||
Reference in New Issue
Block a user