def it_appends_unicode(self):
     qs = {'test3': UNICODE_STRING}
     assert append_qs(URL, qs) == URL_FMT.format(''.join([
         '=&test3=%E0%AE%B8%E0%AF%8D%E0%AE%B1%E0%AF%80%E0%AE%A9%E0%AE%BF',
         '%E0%AE%B5%E0%AE%BE%E0%AE%B8+%E0%AE%B0%E0%AE%BE%E0%AE%AE%E0%AE',
         '%BE%E0%AE%A9%E0%AF%81%E0%AE%9C%E0%AE%A9%E0%AF%8D+%E0%AE%90%E0',
         '%AE%AF%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%BE%E0%AE%B0%E0%AF%8D',
     ]))
Beispiel #2
0
 def it_appends_unicode(self):
     qs = {'test3': UNICODE_STRING}
     assert append_qs(URL, qs) == URL_FMT.format(''.join([
         '=&test3=%E0%AE%B8%E0%AF%8D%E0%AE%B1%E0%AF%80%E0%AE%A9%E0%AE%BF',
         '%E0%AE%B5%E0%AE%BE%E0%AE%B8+%E0%AE%B0%E0%AE%BE%E0%AE%AE%E0%AE',
         '%BE%E0%AE%A9%E0%AF%81%E0%AE%9C%E0%AE%A9%E0%AF%8D+%E0%AE%90%E0',
         '%AE%AF%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%BE%E0%AE%B0%E0%AF%8D',
     ]))
Beispiel #3
0
 def _send_request(self, method, data):
     url = append_qs(self.base_url, {'method': method})
     data, files, headers = self._encode_data(data)
     return self.session.post(url,
                              data=data,
                              files=files,
                              headers=headers,
                              auth=(self.username, self.password),
                              verify=self.verify)
 def it_appends_dict_with_nested_list(self):
     qs = {'test3': ['val1', 'val2']}
     assert append_qs(URL, qs) == URL_FMT.format('=&test3=val1&test3=val2')
 def it_appends_dict(self):
     qs = {'test3': 'val'}
     assert append_qs(URL, qs) == URL_FMT.format('=&test3=val')
 def it_appends_string(self):
     qs = 'test3=val1&test3=val2'
     assert append_qs(URL, qs) == URL_FMT.format('=&' + qs)
Beispiel #7
0
 def _send_request(self, method, data):
     url = append_qs(self.base_url, {'method': method})
     body = self._encode_data(data)
     # httplib2 requires that you manually send Content-Type on POSTs :/
     headers = {'Content-Type': 'application/x-www-form-urlencoded'}
     return self._http.request(url, "POST", body, headers)
Beispiel #8
0
 def test_unicode_qs(self):
     qs = {'test3': UNICODE_STRING}
     utils.append_qs(self.url, qs)
     result = self.result.format('=&test3=%E0%AE%B8%E0%AF%8D%E0%AE%B1%E0%AF%80%E0%AE%A9%E0%AE%BF%E0%AE%B5%E0%AE%BE%E0%AE%B8+%E0%AE%B0%E0%AE%BE%E0%AE%AE%E0%AE%BE%E0%AE%A9%E0%AF%81%E0%AE%9C%E0%AE%A9%E0%AF%8D+%E0%AE%90%E0%AE%AF%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%BE%E0%AE%B0%E0%AF%8D')
     self.assertEqual(utils.append_qs(self.url, qs), result)
Beispiel #9
0
 def it_appends_dict(self):
     qs = {'test3': 'val'}
     assert append_qs(URL, qs) == URL_FMT.format('=&test3=val')
Beispiel #10
0
 def test_dict_qs(self):
     qs = {'test3': 'val'}
     result = self.result.format('=&test3=val')
     self.assertEqual(utils.append_qs(self.url, qs), result)
Beispiel #11
0
 def test_string_qs(self):
     qs = 'test3=val1&test3=val2'
     result = self.result.format('=&test3=val1&test3=val2')
     self.assertEqual(utils.append_qs(self.url, qs), result)
Beispiel #12
0
 def it_raises_type_error_for_bad_query_string_type(self):
     with pytest.raises(TypeError) as e:
         append_qs(URL, object())
     assert str(e.value) == 'Unexpected query_string type'
Beispiel #13
0
 def it_appends_list_of_tuples(self):
     qs = [('test3', 'val1'), ('test3', 'val2')]
     assert append_qs(URL, qs) == URL_FMT.format('=&test3=val1&test3=val2')
Beispiel #14
0
 def it_appends_dict_with_nested_list(self):
     qs = {'test3': ['val1', 'val2']}
     assert append_qs(URL, qs) == URL_FMT.format('=&test3=val1&test3=val2')
 def it_appends_list_of_tuples(self):
     qs = [('test3', 'val1'), ('test3', 'val2')]
     assert append_qs(URL, qs) == URL_FMT.format('=&test3=val1&test3=val2')
Beispiel #16
0
 def test_nested_qs(self):
     qs = {'test3': ['val1', 'val2']}
     result = self.result.format('=&test3=val1&test3=val2')
     self.assertEqual(utils.append_qs(self.url, qs), result)
 def it_raises_type_error_for_bad_query_string_type(self):
     with pytest.raises(TypeError) as e:
         append_qs(URL, object())
     assert str(e.value) == 'Unexpected query_string type'
Beispiel #18
0
 def test_list_qs(self):
     qs = [('test3', 'val1'), ('test3', 'val2')]
     result = self.result.format('=&test3=val1&test3=val2')
     self.assertEqual(utils.append_qs(self.url, qs), result)
Beispiel #19
0
 def _send_request(self, method, data):
     url = append_qs(self.base_url, {'method': method})
     data, files, headers = self._encode_data(data)
     return requests.post(url, data=data, files=files, headers=headers,
                          auth=(self.username, self.password),
                          verify=self.verify)
Beispiel #20
0
 def it_appends_string(self):
     qs = 'test3=val1&test3=val2'
     assert append_qs(URL, qs) == URL_FMT.format('=&' + qs)