예제 #1
0
def test_descriptor_dereference_pointer():
    descriptor = {
        'name': 'name',
        'data': 'data',
        'schema': '#/schemas/main',
        'schemas': {
            'main': {
                'fields': [{
                    'name': 'name'
                }]
            }
        },
    }
    resource = Resource(descriptor)
    assert resource.descriptor == expand({
        'name': 'name',
        'data': 'data',
        'schema': {
            'fields': [{
                'name': 'name'
            }]
        },
        'schemas': {
            'main': {
                'fields': [{
                    'name': 'name'
                }]
            }
        },
    })
예제 #2
0
def test_descriptor_retrieve_dict():
    descriptor = {
        'name': 'name',
        'data': 'data',
    }
    actual = Resource(descriptor).descriptor
    expect = expand(descriptor)
    assert actual == expect
예제 #3
0
def test_descriptor_retrieve_dict():
    descriptor = {
        'name': 'name',
        'data': 'data',
    }
    actual = Resource(descriptor).descriptor
    expect = expand(descriptor)
    assert actual == expect
예제 #4
0
def test_descriptor_dereference():
    descriptor = 'data/resource_with_dereferencing.json'
    resource = Resource(descriptor)
    assert resource.descriptor == expand({
        'name': 'name',
        'data': 'data',
        'schema': {'fields': [{'name': 'name'}]},
        'dialect': {'delimiter': ','},
        'dialects': {'main': {'delimiter': ','}},
    })
예제 #5
0
def test_descriptor_dereference():
    descriptor = 'data/resource_with_dereferencing.json'
    resource = Resource(descriptor)
    assert resource.descriptor == expand({
        'name': 'name',
        'data': 'data',
        'schema': {'fields': [{'name': 'name'}]},
        'dialect': {'delimiter': ','},
        'dialects': {'main': {'delimiter': ','}},
    })
예제 #6
0
def test_descriptor_retrieve_url(patch_get):
    descriptor = 'http://example.com/descriptor.json'
    descriptor_contents = {
        'name': 'name',
        'data': 'data',
    }
    # Mocks
    patch_get(descriptor, body=json.dumps(descriptor_contents))
    # Tests
    actual = Resource(descriptor).descriptor
    expect = expand(descriptor_contents)
    assert actual == expect
예제 #7
0
def test_descriptor_dereference_local():
    descriptor = {
        'name': 'name',
        'data': 'data',
        'schema': 'table_schema.json',
    }
    resource = Resource(descriptor, base_path='data')
    assert resource.descriptor == expand({
        'name': 'name',
        'data': 'data',
        'schema': {'fields': [{'name': 'name'}]},
    })
예제 #8
0
def test_descriptor_retrieve_url(patch_get):
    descriptor = 'http://example.com/descriptor.json'
    descriptor_contents = {
        'name': 'name',
        'data': 'data',
    }
    # Mocks
    patch_get(descriptor, body=json.dumps(descriptor_contents))
    # Tests
    actual = Resource(descriptor).descriptor
    expect = expand(descriptor_contents)
    assert actual == expect
예제 #9
0
def test_descriptor_dereference_local():
    descriptor = {
        'name': 'name',
        'data': 'data',
        'schema': 'table_schema.json',
    }
    resource = Resource(descriptor, base_path='data')
    assert resource.descriptor == expand({
        'name': 'name',
        'data': 'data',
        'schema': {'fields': [{'name': 'name'}]},
    })
예제 #10
0
def test_descriptor_dereference_pointer():
    descriptor = {
        'name': 'name',
        'data': 'data',
        'schema': '#/schemas/main',
        'schemas': {'main': {'fields': [{'name': 'name'}]}},
    }
    resource = Resource(descriptor)
    assert resource.descriptor == expand({
        'name': 'name',
        'data': 'data',
        'schema': {'fields': [{'name': 'name'}]},
        'schemas': {'main': {'fields': [{'name': 'name'}]}},
    })
예제 #11
0
def test_descriptor_dereference_remote(patch_get):
    descriptor = {
        'name': 'name',
        'data': 'data',
        'schema': 'http://example.com/schema',
    }
    # Mocks
    patch_get('http://example.com/schema', body='{"fields": [{"name": "name"}]}')
    # Tests
    resource = Resource(descriptor)
    assert resource.descriptor == expand({
        'name': 'name',
        'data': 'data',
        'schema': {'fields': [{'name': 'name'}]},
    })
예제 #12
0
def test_descriptor_dereference_remote(patch_get):
    descriptor = {
        'name': 'name',
        'data': 'data',
        'schema': 'http://example.com/schema',
    }
    # Mocks
    patch_get('http://example.com/schema', body='{"fields": [{"name": "name"}]}')
    # Tests
    resource = Resource(descriptor)
    assert resource.descriptor == expand({
        'name': 'name',
        'data': 'data',
        'schema': {'fields': [{'name': 'name'}]},
    })
예제 #13
0
def test_descriptor_retrieve_path():
    descriptor = 'data/data-resource.json'
    actual = Resource(descriptor).descriptor
    expect = expand(json.load(io.open(descriptor, encoding='utf-8')))
    assert actual == expect
예제 #14
0
def test_descriptor_retrieve_path():
    descriptor = 'data/data-resource.json'
    actual = Resource(descriptor).descriptor
    expect = expand(json.load(io.open(descriptor, encoding='utf-8')))
    assert actual == expect