Ejemplo n.º 1
0
def test_getUsedSettings(data):
    function = SettingFunction(data["code"])
    answer = function.getUsedSettingKeys()
    assert len(answer) == len(data["variables"])
    for variable in data[
            "variables"]:  # Check for set equality regardless of the order.
        assert variable in answer
Ejemplo n.º 2
0
def test_getUsedSettings(data):
    function = SettingFunction(data["code"])
    answer = function.getUsedSettingKeys()
    assert len(answer) == len(data["variables"])
    for variable in data["variables"]: # Check for set equality regardless of the order.
        assert variable in answer
Ejemplo n.º 3
0
from unittest.mock import patch, MagicMock

import pytest

from UM.Settings.SettingFunction import SettingFunction
from UM.Settings.SettingInstance import InstanceState
from cura.Settings.SettingInheritanceManager import SettingInheritanceManager

setting_function = SettingFunction("")
setting_function.getUsedSettingKeys = MagicMock(return_value=["omg", "zomg"])

setting_property_dict = {
    "setting_1": {},
    "setting_2": {
        "state": InstanceState.User,
        "enabled": False
    },
    "setting_3": {
        "state": InstanceState.User,
        "enabled": True
    },
    "setting_4": {
        "state": InstanceState.User,
        "enabled": True,
        "value": 12
    },
    "setting_5": {
        "state": InstanceState.User,
        "enabled": True,
        "value": setting_function
    }
from unittest.mock import patch, MagicMock

import pytest

from UM.Settings.SettingFunction import SettingFunction
from UM.Settings.SettingInstance import InstanceState
from cura.Settings.SettingInheritanceManager import SettingInheritanceManager

setting_function = SettingFunction("")
setting_function.getUsedSettingKeys = MagicMock(return_value = ["omg", "zomg"])

setting_property_dict = {"setting_1": {},
                         "setting_2": {"state": InstanceState.User, "enabled": False},
                         "setting_3": {"state": InstanceState.User, "enabled": True},
                         "setting_4": {"state": InstanceState.User, "enabled": True, "value": 12},
                         "setting_5": {"state": InstanceState.User, "enabled": True, "value": setting_function}}


def getPropertySideEffect(*args, **kwargs):
    properties = setting_property_dict.get(args[0])
    if properties:
        return properties.get(args[1])


@pytest.fixture
def setting_inheritance_manager():
    with patch("UM.Application.Application.getInstance"):
        with patch("cura.Settings.ExtruderManager.ExtruderManager.getInstance"):
            return SettingInheritanceManager()

@pytest.fixture