コード例 #1
0
ファイル: test_oembed.py プロジェクト: etalab/udata-gouvfr
 def test_oembed_does_not_support_xml(self, api):
     '''It does not support xml format.'''
     dataset = DatasetFactory()
     url = url_for('api.oembed', url=dataset.external_url, format='xml')
     response = api.get(url)
     assert_status(response, 501)
     assert_cors(response)
     assert response.json['message'] == 'Only JSON format is supported'
コード例 #2
0
ファイル: test_oembed.py プロジェクト: etalab/udata-gouvfr
 def test_oembed_for_unknown_dataset(self, api):
     '''It should raise a 404 on missing dataset.'''
     dataset_url = url_for('datasets.show', dataset='unknown',
                           _external=True)
     url = url_for('api.oembed', url=dataset_url)
     response = api.get(url)
     assert404(response)
     assert_cors(response)
コード例 #3
0
ファイル: test_oembed_api.py プロジェクト: rfResearch/udata
    def test_oembed_for_dataset_with_organization(self, api):
        '''It should fetch a dataset in the oembed format with org.'''
        organization = OrganizationFactory()
        dataset = DatasetFactory(organization=organization)

        url = url_for('api.oembed', url=dataset.external_url)
        response = api.get(url)
        assert200(response)
        assert_cors(response)

        card = theme.render('dataset/card.html', dataset=dataset)
        assert card in response.json['html']
コード例 #4
0
ファイル: test_oembed.py プロジェクト: etalab/udata-gouvfr
    def test_oembed_for_reuse(self, api):
        '''It should fetch a reuse in the oembed format.'''
        reuse = ReuseFactory()

        url = url_for('api.oembed', url=reuse.external_url)
        response = api.get(url)
        assert200(response)
        assert_cors(response)
        assert 'html' in response.json
        assert 'width' in response.json
        assert 'maxwidth' in response.json
        assert 'height' in response.json
        assert 'maxheight' in response.json
        assert response.json['type'] == 'rich'
        assert response.json['version'] == '1.0'
        card = theme.render('reuse/card.html', reuse=reuse)
        assert card in response.json['html']
コード例 #5
0
ファイル: test_oembed.py プロジェクト: etalab/udata-gouvfr
    def test_oembed_for_org(self, api):
        '''It should fetch an organization in the oembed format.'''
        org = OrganizationFactory()

        url = url_for('api.oembed', url=org.external_url)
        response = api.get(url)
        assert200(response)
        assert_cors(response)
        assert 'html' in response.json
        assert 'width' in response.json
        assert 'maxwidth' in response.json
        assert 'height' in response.json
        assert 'maxheight' in response.json
        assert response.json['type'] == 'rich'
        assert response.json['version'] == '1.0'
        card = theme.render('organization/card.html', organization=org)
        assert card in response.json['html']
コード例 #6
0
ファイル: test_oembed_api.py プロジェクト: rfResearch/udata
    def test_oembed_for_dataset(self, api):
        '''It should fetch a dataset in the oembed format.'''
        dataset = DatasetFactory()

        url = url_for('api.oembed', url=dataset.external_url)
        response = api.get(url)
        assert200(response)
        assert_cors(response)
        assert 'html' in response.json
        assert 'width' in response.json
        assert 'maxwidth' in response.json
        assert 'height' in response.json
        assert 'maxheight' in response.json
        assert response.json['type'] == 'rich'
        assert response.json['version'] == '1.0'
        card = theme.render('dataset/card.html', dataset=dataset)
        assert card in response.json['html']
コード例 #7
0
ファイル: test_oembed.py プロジェクト: etalab/udata-gouvfr
    def test_oembed_for_dataset_redirect_link(self, api):
        '''It should fetch an oembed dataset using the redirect link.'''
        dataset = DatasetFactory()
        redirect_url = url_for('datasets.show_redirect',
                               dataset=dataset, _external=True)

        url = url_for('api.oembed', url=redirect_url)
        response = api.get(url)
        assert200(response)
        assert_cors(response)
        assert 'html' in response.json
        assert 'width' in response.json
        assert 'maxwidth' in response.json
        assert 'height' in response.json
        assert 'maxheight' in response.json
        assert response.json['type'] == 'rich'
        assert response.json['version'] == '1.0'
        card = theme.render('dataset/card.html', dataset=dataset)
        assert card in response.json['html']
コード例 #8
0
ファイル: test_oembed.py プロジェクト: etalab/udata-gouvfr
 def test_oembed_with_an_unknown_url(self, api):
     '''It should fail at fetching an oembed with an invalid URL.'''
     url = url_for('api.oembed', url='http://local.test/somewhere')
     response = api.get(url)
     assert404(response)
     assert_cors(response)