Ejemplo n.º 1
0
Archivo: api.py Proyecto: refaim/vk
    def __call__(self, method, timeout=None, **kwargs):
        response = self._request(method, timeout=timeout, **kwargs)
        response.raise_for_status()

        # there are may be 2 dicts in 1 json
        # for example: {'error': ...}{'response': ...}
        errors = []
        for data in json_iter_parse(response.text):
            if 'error' in data:
                errors.append(data['error'])

            if 'response' in data:
                for error in errors:
                    warnings.warn(str(error))

                return make_handy(data['response'])

        raise VkAPIError(errors[0])
Ejemplo n.º 2
0
Archivo: tests.py Proyecto: ForkLab/vk
 def test_handy_dict(self):
     handy_dict = make_handy({'key1': 'val1', 'key2': 'val2'})
     self.assertIsInstance(handy_dict, HandyDict)
     self.assertEqual(handy_dict.key1, 'val1')
Ejemplo n.º 3
0
Archivo: tests.py Proyecto: ForkLab/vk
 def test_list(self):
     handy_list = make_handy([1, 2, 3])
     self.assertIsInstance(handy_list, HandyList)
     self.assertEqual(handy_list.first, 1)
Ejemplo n.º 4
0
Archivo: tests.py Proyecto: ForkLab/vk
 def test_get_profiles_via_token(self):
     profiles = self.vk_api.users.get(user_id=1)
     profiles = make_handy(profiles)
     self.assertEqual(profiles.first.last_name, u'Дуров')
Ejemplo n.º 5
0
 def test_handy_dict(self):
     handy_dict = make_handy({'key1': 'val1', 'key2': 'val2'})
     self.assertIsInstance(handy_dict, HandyDict)
     self.assertEqual(handy_dict.key1, 'val1')
Ejemplo n.º 6
0
 def test_list(self):
     handy_list = make_handy([1, 2, 3])
     self.assertIsInstance(handy_list, HandyList)
     self.assertEqual(handy_list.first, 1)
Ejemplo n.º 7
0
 def test_get_profiles_via_token(self):
     profiles = self.vk_api.users.get(user_id=1)
     profiles = make_handy(profiles)
     self.assertEqual(profiles.first.last_name, u'Дуров')
Ejemplo n.º 8
0
Archivo: tests.py Proyecto: refaim/vk
 def test_handy_dict(self):
     handy_dict = make_handy({"key1": "val1", "key2": "val2"})
     self.assertIsInstance(handy_dict, HandyDict)
     self.assertEqual(handy_dict.key1, "val1")