Commits

Sybren Stüvel committed b2da3ef

Added test + fixed bug in passing format parameter

  • Participants
  • Parent commits 97d1c40

Comments (0)

Files changed (2)

File flickrapi/core.py

 
         # Set some defaults
         defaults = {'method': method_name,
-                    'nojsoncallback': 1,
                     'format': self.default_format}
+        if 'jsoncallback' not in kwargs:
+            defaults['nojsoncallback'] = 1
         params = self._supply_defaults(params, defaults)
 
         LOG.info('Calling %s', defaults)
 
         # Find the parser, and set the format to rest if we're supposed to
         # parse it.
-        if parse_format in rest_parsers:
+        if parse_format in rest_parsers and 'format' in kwargs:
             kwargs['format'] = rest_parsers[parse_format][1]
 
-        LOG.debug('Wrapping call %s(self, %s, %s)' % (wrapped_method, args,
-            kwargs))
+        LOG.debug('Wrapping call %s(self, %s, %s)' % (wrapped_method, args, kwargs))
         data = wrapped_method(*args, **kwargs)
 
         # Just return if we have no parser

File tests/test_flicrkapi.py

         self.assertEqual(photo['photo']['id'], '2333478006')
         self.assertEqual(locality['_content'], 'Amsterdam')
 
+    def test_json_callback_format(self):
+        '''Test json format (with callback)'''
+
+        data = self.f_noauth.photos.getInfo(photo_id='2333478006',
+                                            format='json',
+                                            jsoncallback='foobar')
+        decoded = data.decode('utf-8')
+        self.assertEqual('foobar({', decoded[:8])
+
 
 class WalkerTest(SuperTest):
     '''Tests walk* functions.'''