46 lines
893 B
Python
46 lines
893 B
Python
from pytest import fixture
|
|
from pathlib import Path
|
|
|
|
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_file": Path(res_path + in_file),
|
|
"out": Path(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
|
|
|