Exemplo n.º 1
0
def test_qualified_discovery_replaced():
    result = QualifiedDiscovery(
        preexisting=([
            {
                "key": "a",
                "value": "1"
            },
            {
                "key": "b",
                "value": "1"
            },
        ]),
        current=([
            {
                "key": "a",
                "value": "1"
            },
            {
                "key": "b",
                "value": "2"
            },
        ]),
        key=lambda item: item["key"] + ":" + item["value"],
    )

    assert result.vanished == [{'key': 'b', 'value': '1'}]
    assert result.old == [{'key': 'a', 'value': '1'}]
    assert result.new == [{'key': 'b', 'value': '2'}]
    assert result.present == [{'key': 'a', 'value': '1'}, {'key': 'b', 'value': '2'}]
Exemplo n.º 2
0
def test_qualified_discovery():

    result = QualifiedDiscovery(
        preexisting=(1, 2),
        current=(2, 3),
        key=lambda x: x,
    )

    assert result.vanished == [1]
    assert result.old == [2]
    assert result.new == [3]
    assert result.present == [2, 3]

    assert list(result.chain_with_qualifier()) == [
        ("vanished", 1),
        ("old", 2),
        ("new", 3),
    ]
Exemplo n.º 3
0
def test_qualified_discovery():

    result = QualifiedDiscovery(
        preexisting=(1, 2),
        current=(2, 3),
        key=lambda x: x,
    )

    assert result.vanished == [1]
    assert result.old == [2]
    assert result.new == [3]
    assert result.present == [2, 3]
Exemplo n.º 4
0
def test_qualified_discovery_keeps_old():

    # e.g.: same service, different parameters
    result = QualifiedDiscovery(
        preexisting=["this is old"],
        current=["this is new"],
        key=lambda x: x[:6],
    )

    assert not result.vanished
    assert result.old == ["this is old"]
    assert not result.new
    assert result.present == ["this is old"]