Skip to content
Snippets Groups Projects
test_lnetd_routes.py 682 B
import json
import jsonschema
import pytest
from inventory_provider.routes.lnetd import INTERFACE_LIST_SCHEMA

DEFAULT_REQUEST_HEADERS = {
    'Accept': ['application/json']
}


def test_router_interfaces(router, client):
    if router.startswith('qfx'):
        pytest.skip('no interfaces expected for {router}, skipping')

    rv = client.post(
        f'/LnetD/interfaces/{router}',
        headers=DEFAULT_REQUEST_HEADERS)

    assert rv.status_code == 200
    response = json.loads(rv.data.decode('utf-8'))
    jsonschema.validate(response, INTERFACE_LIST_SCHEMA)
    assert response  # at least shouldn't be empty
    assert all(ifc['hostname'] == router for ifc in response)