Example #1
0
def test_should_not_find_oembed_urls_for_bad_format():
    with pytest.raises(discovery.PyEmbedDiscoveryError):
        discoverer = discovery.FileDiscoverer(
            'pyembed/core/test/fixtures/static_discovery/valid.json')
        next(
            discoverer.get_oembed_urls('http://example.com/simple/123',
                                       'yaml'))
Example #2
0
def test_should_find_oembed_urls_for_json():
    discoverer = discovery.FileDiscoverer(
        'pyembed/core/test/fixtures/static_discovery/valid.json')
    result = discoverer.get_oembed_urls('http://example.com/simple/123',
                                        'json')
    assert list(result) == \
        ['http://example.com/simple/oembed?url=http%3A%2F%2Fexample.com%2Fsimple%2F123&format=json']
Example #3
0
def test_should_find_oembed_urls_for_subdomain_wildcard_with_subdomain():
    discoverer = discovery.FileDiscoverer(
        'pyembed/core/test/fixtures/static_discovery/valid.json')
    result = discoverer.get_oembed_urls('http://www.example.com/sub/123')
    assert list(result) == [
        'http://example.com/sub/oembed?url=http%3A%2F%2Fwww.example.com%2Fsub%2F123&format=json',
        'http://example.com/sub/oembed?url=http%3A%2F%2Fwww.example.com%2Fsub%2F123&format=xml'
    ]
Example #4
0
def test_should_find_oembed_urls_when_format_in_endpoint():
    discoverer = discovery.FileDiscoverer(
        'pyembed/core/test/fixtures/static_discovery/valid.json')
    result = discoverer.get_oembed_urls('http://example.com/format/123')
    assert list(result) == [
        'http://example.com/format/oembed.json?url=http%3A%2F%2Fexample.com%2Fformat%2F123&format=json',
        'http://example.com/format/oembed.xml?url=http%3A%2F%2Fexample.com%2Fformat%2F123&format=xml'
    ]
Example #5
0
def test_should_find_oembed_urls_when_split_by_format():
    discoverer = discovery.FileDiscoverer(
        'pyembed/core/test/fixtures/static_discovery/valid.json')
    result = discoverer.get_oembed_urls('http://example.com/split/123')

    assert list(result) == [
        'http://example.com/split_xml/oembed?url=http%3A%2F%2Fexample.com%2Fsplit%2F123&format=xml',
        'http://example.com/split_json/oembed?url=http%3A%2F%2Fexample.com%2Fsplit%2F123&format=json'
    ]
Example #6
0
def test_should_find_oembed_urls_for_xml_when_only_xml_allowed():
    discoverer = discovery.FileDiscoverer(
        'pyembed/core/test/fixtures/static_discovery/valid.json')
    result = discoverer.get_oembed_urls('http://example.com/xml/123', 'xml')
    assert list(result) == \
        ['http://example.com/xml/oembed?url=http%3A%2F%2Fexample.com%2Fxml%2F123&format=xml']
Example #7
0
def test_should_not_find_oembed_urls_for_xml_when_only_json_allowed():
    discoverer = discovery.FileDiscoverer(
        'pyembed/core/test/fixtures/static_discovery/valid.json')
    result = discoverer.get_oembed_urls('http://example.com/json/123', 'xml')
    assert list(result) == []
Example #8
0
def test_should_not_find_oembed_urls_for_unknown_url():
    discoverer = discovery.FileDiscoverer(
        'pyembed/core/test/fixtures/static_discovery/valid.json')
    result = discoverer.get_oembed_urls('http://example.com/rubbish/123')
    assert list(result) == []
Example #9
0
def test_should_throw_if_empty_schemes():
    discovery.FileDiscoverer(
        'pyembed/core/test/fixtures/static_discovery/empty_schemes.json')
Example #10
0
def test_should_cope_with_no_endpoint():
    discovery.FileDiscoverer(
        'pyembed/core/test/fixtures/static_discovery/no_endpoint.json')