Ejemplo n.º 1
0
def test_get_object_callable_called(mocked_get_context, basic_object):
    """Test if Accessor.get() calls Accessor.getter() if getter is callable."""
    acc = Accessor()
    acc.getter = mock.Mock()
    acc.get(basic_object)

    acc.getter.assert_called_once_with(basic_object)
Ejemplo n.º 2
0
def test_get_object_callable_called(mocked_get_context, basic_object):
    """Test if Accessor.get() calls Accessor.getter() if getter is callable."""
    acc = Accessor()
    acc.getter = mock.Mock()
    acc.get(basic_object)

    acc.getter.assert_called_once_with(basic_object)
Ejemplo n.º 3
0
def test_set_object_nested_dotted(basic_object, basic_object_value):
    """Test if accessor.get() correctly navigates nested values."""
    acc = Accessor(getter="value.key.key", setter="value.key.key")

    acc.set(basic_object, "")
    assert acc.get(basic_object) == ""

    acc.set(basic_object, "value")
    assert acc.get(basic_object) == "value"
Ejemplo n.º 4
0
def test_set_object_nested_dotted(basic_object, basic_object_value):
    """Test if accessor.get() correctly navigates nested values."""
    acc = Accessor(getter="value.key.key", setter="value.key.key")

    acc.set(basic_object, "")
    assert acc.get(basic_object) == ""

    acc.set(basic_object, "value")
    assert acc.get(basic_object) == "value"
Ejemplo n.º 5
0
def test_get_dict_string(basic_dict_value, basic_dict):
    """Test return value of get with dict.

    Test if Accessor.get() returns correct results for an object,
    when used with a callable getter.
    """
    acc = Accessor(getter="value")
    assert acc.get(basic_dict) == basic_dict_value
Ejemplo n.º 6
0
def test_get_dict_string(basic_dict_value, basic_dict):
    """Test return value of get with dict.

    Test if Accessor.get() returns correct results for an object,
    when used with a callable getter.
    """
    acc = Accessor(getter="value")
    assert acc.get(basic_dict) == basic_dict_value
Ejemplo n.º 7
0
def test_get_object_string(basic_object, basic_object_value):
    """Test if Accessor.get() returns correct results when used with a dotted string."""
    acc = Accessor(getter="value")
    assert acc.get(basic_object) == basic_object_value
Ejemplo n.º 8
0
def test_get_object_string(basic_object, basic_object_value):
    """Test if Accessor.get() returns correct results when used with a dotted string."""
    acc = Accessor(getter="value")
    assert acc.get(basic_object) == basic_object_value