Test: convert_template
This commit is contained in:
@@ -1,9 +1,3 @@
|
||||
// Arduino ProMicro atmega32u4au
|
||||
// Params
|
||||
// orientation: default is down
|
||||
// if down, power led will face the pcb
|
||||
// if up, power led will face away from pcb
|
||||
|
||||
module.exports = {
|
||||
params: {
|
||||
designator: 'MCU',
|
||||
@@ -126,4 +120,4 @@ module.exports = {
|
||||
`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,43 @@
|
||||
from ergogen_footprint_converter.converter import Converter
|
||||
|
||||
def test_convert():
|
||||
input = ""
|
||||
converter = Converter(input)
|
||||
import pytest
|
||||
|
||||
from kiutils.footprint import Footprint
|
||||
|
||||
@pytest.fixture
|
||||
def footprint():
|
||||
return Footprint.create_new("test", "test")
|
||||
|
||||
@pytest.fixture
|
||||
def template() -> str:
|
||||
return open("res/template.js").read()
|
||||
|
||||
def test_empty(footprint, template):
|
||||
converter = Converter(footprint)
|
||||
|
||||
res = converter.convert()
|
||||
|
||||
expected = """
|
||||
(module test)
|
||||
"""
|
||||
|
||||
assert res == expected
|
||||
|
||||
def test_replace_template(template: str):
|
||||
replacements = {
|
||||
"{% params %}": "one",
|
||||
"{% main %}": "two",
|
||||
"{% captions %}": "three",
|
||||
"{% pins %}": "four"
|
||||
}
|
||||
|
||||
for key in replacements:
|
||||
template = template.replace(key, replacements[key])
|
||||
|
||||
res = Converter.replace_template("one", "two", "three", "four")
|
||||
|
||||
assert res == template
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user