Skip to content
Snippets Groups Projects
Select Git revision
  • 83c12d27c1ade5b10a2c4a7fd768c9db19cc8ce2
  • 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_general_routes.py

Blame
  • test_general_routes.py 2.11 KiB
    import json
    import jsonschema
    
    from inventory_provider.routes import common
    from inventory_provider.routes.default import VERSION_SCHEMA
    
    DEFAULT_REQUEST_HEADERS = {
        'Content-type': 'application/json',
        'Accept': ['application/json']
    }
    
    
    def test_version_request(client, mocked_redis):
    
        rv = client.post(
            'version',
            headers=DEFAULT_REQUEST_HEADERS)
        assert rv.status_code == 200
        jsonschema.validate(
            json.loads(rv.data.decode('utf-8')),
            VERSION_SCHEMA)
    
    
    def test_load_json_docs(data_config, mocked_redis):
    
        INTERFACE_SCHEMA = {
            '$schema': 'http://json-schema.org/draft-07/schema#',
    
            'definitions': {
                'interface': {
                    'type': 'object',
                    'properties': {
                        'logical-system': {'type': 'string'},
                        'name': {'type': 'string'},
                        'description': {'type': 'string'},
                        'bundle': {
                            'type': 'array',
                            'items': {'type': 'string'}
                        },
                        'ipv4': {
                            'type': 'array',
                            'items': {'type': 'string'}
                        },
                        'ipv6': {
                            'type': 'array',
                            'items': {'type': 'string'}
                        }
                    },
                    'required': ['name', 'description', 'ipv4', 'ipv6'],
                    'additionalProperties': False
                }
            },
    
            'type': 'object',
            'properties': {
                'key': {'type': 'string'},
                'value': {'$ref': '#/definitions/interface'}
            },
            'required': ['key', 'value'],
            'additionalProperties': False
        }
    
        for ifc in common.load_json_docs(
                data_config, 'netconf-interfaces:*', num_threads=20):
            jsonschema.validate(ifc, INTERFACE_SCHEMA)
    
    
    def test_ping_post(client):
        rv = client.post('ping')
        assert rv.status_code == 204
        assert len(rv.data) == 0
    
    
    def test_ping_get(client):
        rv = client.get('ping')
        assert rv.status_code == 204
        assert len(rv.data) == 0