WIP
This commit is contained in:
@@ -3,46 +3,55 @@ from ergogen_footprint_converter.converter import Converter
|
||||
import pytest
|
||||
|
||||
from kiutils.footprint import Footprint
|
||||
from kiutils.items.fpitems import FpText
|
||||
|
||||
@pytest.fixture
|
||||
def main_rendered ():
|
||||
return """
|
||||
(module "test" (version 20211014) (generator kiutils)
|
||||
(layer "F.Cu")
|
||||
(tedit 64de79c2)
|
||||
)
|
||||
"""
|
||||
|
||||
@pytest.fixture
|
||||
def footprint():
|
||||
footprint = Footprint.create_new("test", "test")
|
||||
footprint.tedit = "64de79c2"
|
||||
print(footprint)
|
||||
footprint.graphicItems = []
|
||||
|
||||
return footprint
|
||||
|
||||
@pytest.fixture
|
||||
def template() -> str:
|
||||
return open("res/template.js").read()
|
||||
|
||||
def test_empty_footprint(footprint, template):
|
||||
strip = lambda s: ''.join([x.strip() for x in s.split()])
|
||||
|
||||
def test_empty_footprint(footprint, template, main_rendered):
|
||||
converter = Converter(footprint)
|
||||
|
||||
strip = lambda s: ''.join([x.strip() for x in s.split()])
|
||||
res = strip(converter.convert().strip('\n').strip())
|
||||
|
||||
main = """
|
||||
(module "test" (version 20211014) (generator kiutils)
|
||||
(layer "F.Cu")
|
||||
(tedit 64de79c2)
|
||||
(fp_text reference "REF**" (at 0 -0.5 unlocked) (layer "F.SilkS")
|
||||
(effects (font (size 1.0 1.0) (thickness 0.15)))
|
||||
)
|
||||
(fp_text value "test" (at 0 1 unlocked) (layer "F.Fab")
|
||||
(effects (font (size 1.0 1.0) (thickness 0.15)))
|
||||
)
|
||||
(fp_text user "${REFERENCE}" (at 0 2.5 unlocked) (layer "F.Fab")
|
||||
(effects (font (size 1.0 1.0) (thickness 0.15)))
|
||||
)
|
||||
)
|
||||
"""
|
||||
|
||||
expected = strip(Converter.replace_template(template, "", main, "", ""))
|
||||
expected = strip(Converter.replace_template(template, "", main_rendered, "", ""))
|
||||
|
||||
assert res == expected
|
||||
|
||||
def test_caption(template):
|
||||
None
|
||||
def test_contains_caption(footprint: Footprint, template: str, main_rendered):
|
||||
first_item = FpText("Test 1")
|
||||
second_item =FpText("Test 2")
|
||||
captions = [first_item, second_item]
|
||||
captions_str = ''.join(list(map(lambda x: x.to_sexpr().join('\n'), captions)))
|
||||
print(captions_str)
|
||||
|
||||
footprint.graphicItems = captions
|
||||
|
||||
result = strip(Converter(footprint).convert())
|
||||
|
||||
|
||||
expected = strip(Converter.replace_template(template, "", main_rendered, captions_str, ""))
|
||||
|
||||
assert result == expected
|
||||
|
||||
|
||||
def test_replace_template(template: str):
|
||||
|
||||
Reference in New Issue
Block a user