Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c1da59

Browse files
committed
Test case for build_query
1 parent 470195a commit 1c1da59

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

tests/test_model.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding:utf-8 -*-
12
#!/usr/bin/python2.4
23
#
34
# Copyright 2014 Google Inc. All Rights Reserved.
@@ -21,9 +22,9 @@
2122

2223
__author__ = '[email protected] (Joe Gregorio)'
2324

24-
import httplib2
2525
import unittest
2626

27+
from googleapiclient.model import BaseModel
2728
from googleapiclient.model import makepatch
2829

2930

@@ -67,5 +68,27 @@ def test_patch(self):
6768
self.assertEqual(expected_patch, makepatch(orig, mod), msg=msg)
6869

6970

71+
class TestBaseModel(unittest.TestCase):
72+
def test_build_query(self):
73+
model = BaseModel()
74+
75+
test_cases = [
76+
('hello', 'world', '?hello=world'),
77+
('hello', u'world', '?hello=world'),
78+
('hello', '세계', '?hello=%EC%84%B8%EA%B3%84'),
79+
('hello', u'세계', '?hello=%EC%84%B8%EA%B3%84'),
80+
('hello', 'こんにちは', '?hello=%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF'),
81+
('hello', u'こんにちは', '?hello=%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF'),
82+
('hello', '你好', '?hello=%E4%BD%A0%E5%A5%BD'),
83+
('hello', u'你好', '?hello=%E4%BD%A0%E5%A5%BD'),
84+
('hello', 'مرحبا', '?hello=%D9%85%D8%B1%D8%AD%D8%A8%D8%A7'),
85+
('hello', u'مرحبا', '?hello=%D9%85%D8%B1%D8%AD%D8%A8%D8%A7')
86+
]
87+
88+
for case in test_cases:
89+
key, value, expect = case
90+
self.assertEqual(expect, model._build_query({key: value}))
91+
92+
7093
if __name__ == '__main__':
7194
unittest.main()

0 commit comments

Comments
 (0)