Beispiel #1
0
    def test_oembed_handles_max_dim_params_valid(self, registry):
        provider = Mock()
        provider.expose = True
        registry.match.return_value = provider

        self.request.GET = {'url': 'foo', 'maxwidth': '100', 'maxheight': '200'}
        oembed(self.request)
        provider.get_resource.assert_called_with('foo', maxwidth=100, maxheight=200)
Beispiel #2
0
    def test_oembed_not_found_provider(self, registry):
        self.request.GET = {'url': 'foo'}

        registry.match.return_value = None
        self.assertEqual(404, self._oembed_status())

        fake_provider = Mock()
        fake_provider.expose = False
        registry.match.return_value = fake_provider
        self.assertEqual(404, self._oembed_status())
Beispiel #3
0
    def test_oembed_handles_jsonp_callbacks(self, registry):
        resource = Mock()
        resource.json = '{"foo": "bar"}'
        provider = Mock()
        provider.expose = True
        provider.get_resource.return_value = resource
        registry.match.return_value = provider

        self.request.GET = {'url': 'foo', 'callback': 'acallback'}
        response = oembed(self.request)
        self.assertEqual('acallback({"foo": "bar"});', response.content)