async def test_negative(mock_aioresponses):
    RECIPE_42 = {"id": "42", "recipe": {"id": 42, "name": "Extra"}}
    mock_aioresponses.get(
        NORMANDY_URL.format(server=NORMANDY_SERVER, baseline_only=0),
        payload=[NORMANDY_RECIPE, REMOTESETTINGS_RECIPE_WITH_CAPS],
    )
    mock_aioresponses.get(
        NORMANDY_URL.format(server=NORMANDY_SERVER, baseline_only=1),
        payload=[NORMANDY_RECIPE],
    )
    mock_aioresponses.get(
        REMOTESETTINGS_CAPABILITIES_URL,
        payload={"data": [REMOTESETTINGS_RECIPE_WITH_CAPS]},
    )
    mock_aioresponses.get(
        REMOTESETTINGS_BASELINE_URL,
        payload={"data": [RECIPE_42]},
    )
    status, data = await run(NORMANDY_SERVER, REMOTESETTINGS_SERVER)

    assert status is False
    assert data == {
        "baseline": {
            "missing": [_d(REMOTESETTINGS_RECIPE)],
            "extras": [_d(RECIPE_42)],
        },
        "capabilities": {
            "missing": [_d(REMOTESETTINGS_RECIPE)],
            "extras": []
        },
    }
async def test_positive(mock_aioresponses):
    mock_aioresponses.get(
        NORMANDY_URL.format(server=NORMANDY_SERVER, baseline_only=0),
        payload=[NORMANDY_RECIPE, REMOTESETTINGS_RECIPE_WITH_CAPS],
    )
    mock_aioresponses.get(
        NORMANDY_URL.format(server=NORMANDY_SERVER, baseline_only=1),
        payload=[NORMANDY_RECIPE],
    )
    mock_aioresponses.get(
        REMOTESETTINGS_CAPABILITIES_URL,
        payload={
            "data": [REMOTESETTINGS_RECIPE, REMOTESETTINGS_RECIPE_WITH_CAPS]
        },
    )
    mock_aioresponses.get(REMOTESETTINGS_BASELINE_URL,
                          payload={"data": [REMOTESETTINGS_RECIPE]})

    status, data = await run(NORMANDY_SERVER, REMOTESETTINGS_SERVER)

    assert status is True
    assert data == {
        "baseline": {
            "missing": [],
            "extras": []
        },
        "capabilities": {
            "missing": [],
            "extras": []
        },
    }
Beispiel #3
0
async def test_positive(mock_aioresponses):
    mock_aioresponses.get(
        NORMANDY_URL.format(server=NORMANDY_SERVER, baseline_only=0),
        payload=[NORMANDY_RECIPE, REMOTESETTINGS_RECIPE_WITH_CAPS],
    )
    mock_aioresponses.get(
        NORMANDY_URL.format(server=NORMANDY_SERVER, baseline_only=1),
        payload=[NORMANDY_RECIPE],
    )
    mock_aioresponses.get(
        REMOTESETTINGS_CAPABILITIES_URL,
        payload={
            "changes":
            [REMOTESETTINGS_RECIPE, REMOTESETTINGS_RECIPE_WITH_CAPS]
        },
    )
    mock_aioresponses.get(REMOTESETTINGS_BASELINE_URL,
                          payload={"changes": [REMOTESETTINGS_RECIPE]})

    with mock.patch("checks.normandy.remotesettings_recipes.random.randint",
                    return_value=42):
        status, data = await run(NORMANDY_SERVER, REMOTESETTINGS_SERVER)

    assert status is True
    assert data == {
        "baseline": {
            "missing": [],
            "extras": []
        },
        "capabilities": {
            "missing": [],
            "extras": []
        },
    }