Skip to content
Snippets Groups Projects
Select Git revision
  • fbfc3afde2a0a591e4da7faabbd8b7e88e1a0ef2
  • develop default
  • master protected
  • inventoryProvider-functional
  • inventoryProvider-morework2
  • circuit-service-details-fix
  • lookup-SPECTRUM-SCHF-ports
  • inventoryProvider-1267-cleanup
  • inventoryProvider-moreWork
  • feature/DBOARD3-958
  • release/0.110
  • fix-uuid-validation-error
  • docker-poc
  • 0.161
  • 0.160
  • 0.159
  • 0.158
  • 0.157
  • 0.156
  • 0.155
  • 0.154
  • 0.153
  • 0.152
  • 0.151
  • 0.150
  • 0.149
  • 0.148
  • 0.147
  • 0.146
  • 0.145
  • 0.144
  • 0.143
  • 0.142
33 results

test_neteng_routes.py

Blame
  • test_neteng_routes.py 1.67 KiB
    import json
    import jsonschema
    import pytest
    
    from inventory_provider.db.ims_data \
        import NODE_LOCATION_SCHEMA, POP_LOCATION_SCHEMA
    from inventory_provider.routes.neteng import STRING_LIST_SCHEMA
    
    
    @pytest.mark.parametrize('equipment_name', [
        'MX1.AMS.NL',
        'MIL-OLA1',
        'LON02-GRV1'
    ])
    def test_location(client, mocked_redis, equipment_name):
        rv = client.get(
            f'/neteng/location/{equipment_name}',
            headers={'Accept': ['application/json']})
        assert rv.status_code == 200
        jsonschema.validate(
            json.loads(rv.data.decode('utf-8')),
            NODE_LOCATION_SCHEMA)
    
    
    def test_location_not_found(client, mocked_redis):
        rv = client.get(
            '/neteng/location/BOGUS.EQUIPMENT.NAME',
            headers={'Accept': ['application/json']})
        assert rv.status_code == 404
    
    
    def test_get_pops(client, mocked_redis):
        rv = client.get(
            '/neteng/pops',
            headers={'Accept': ['application/json']})
        assert rv.status_code == 200
        jsonschema.validate(
            json.loads(rv.data.decode('utf-8')),
            STRING_LIST_SCHEMA)
    
    
    @pytest.mark.parametrize('pop_name', [
        'AMS', 'LON', 'COR', 'ORB', 'ORBE',
    ])
    def test_pop_location(client, mocked_redis, pop_name):
        rv = client.get(
            f'/neteng/pop/{pop_name}',
            headers={'Accept': ['application/json']})
        assert rv.status_code == 200
        jsonschema.validate(
            json.loads(rv.data.decode('utf-8')),
            POP_LOCATION_SCHEMA)
        s = json.loads(rv.data.decode('utf-8'))
        print(s)
    
    
    def test_pop_not_found(client, mocked_redis):
        rv = client.get(
            '/neteng/pop/BOGUS.POP.ABBREV',
            headers={'Accept': ['application/json']})
        assert rv.status_code == 404