mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 22:54:01 -06:00
Add test for prepareLocal
Contributes to issue CURA-5929.
This commit is contained in:
parent
0bf7bf4cbe
commit
91e8c177fe
1 changed files with 39 additions and 4 deletions
|
@ -1,9 +1,10 @@
|
||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2018 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import pytest #To register tests with.
|
import configparser # An input for some functions we're testing.
|
||||||
|
import pytest # To register tests with.
|
||||||
|
|
||||||
from LegacyProfileReader import LegacyProfileReader #The module we're testing.
|
from LegacyProfileReader import LegacyProfileReader # The module we're testing.
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def legacy_profile_reader():
|
def legacy_profile_reader():
|
||||||
|
@ -11,7 +12,8 @@ def legacy_profile_reader():
|
||||||
|
|
||||||
test_prepareDefaultsData = [
|
test_prepareDefaultsData = [
|
||||||
{
|
{
|
||||||
"defaults": {
|
"defaults":
|
||||||
|
{
|
||||||
"foo": "bar"
|
"foo": "bar"
|
||||||
},
|
},
|
||||||
"cheese": "delicious"
|
"cheese": "delicious"
|
||||||
|
@ -28,4 +30,37 @@ def test_prepareDefaults(legacy_profile_reader, input):
|
||||||
if "defaults" in input:
|
if "defaults" in input:
|
||||||
assert input["defaults"] == output
|
assert input["defaults"] == output
|
||||||
else:
|
else:
|
||||||
assert output == {}
|
assert output == {}
|
||||||
|
|
||||||
|
test_prepareLocalsData = [
|
||||||
|
(
|
||||||
|
{ # Parser data.
|
||||||
|
"profile":
|
||||||
|
{
|
||||||
|
"layer_height": "0.2",
|
||||||
|
"infill_density": "30"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profile", # Config section.
|
||||||
|
{ # Defaults.
|
||||||
|
"layer_height": "0.1",
|
||||||
|
"infill_density": "20",
|
||||||
|
"line_width": "0.4"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("parser_data, config_section, defaults", test_prepareLocalsData)
|
||||||
|
def test_prepareLocals(legacy_profile_reader, parser_data, config_section, defaults):
|
||||||
|
parser = configparser.ConfigParser()
|
||||||
|
parser.read_dict(parser_data)
|
||||||
|
|
||||||
|
output = legacy_profile_reader.prepareLocals(parser, config_section, defaults)
|
||||||
|
|
||||||
|
assert set(defaults.keys()) <= set(output.keys()) # All defaults must be in there.
|
||||||
|
assert set(parser_data[config_section]) <= set(output.keys()) # All overwritten values must be in there.
|
||||||
|
for key in output:
|
||||||
|
if key in parser_data[config_section]:
|
||||||
|
assert output[key] == parser_data[config_section][key] # If overwritten, must be the overwritten value.
|
||||||
|
else:
|
||||||
|
assert output[key] == defaults[key] # Otherwise must be equal to the default.
|
Loading…
Add table
Add a link
Reference in a new issue