|
| 1 | +# -*- coding:utf-8 -*- |
1 | 2 | #!/usr/bin/python2.4
|
2 | 3 | #
|
3 | 4 | # Copyright 2014 Google Inc. All Rights Reserved.
|
|
21 | 22 |
|
22 | 23 | __author__ = '[email protected] (Joe Gregorio)'
|
23 | 24 |
|
24 |
| -import httplib2 |
25 | 25 | import unittest
|
26 | 26 |
|
| 27 | +from googleapiclient.model import BaseModel |
27 | 28 | from googleapiclient.model import makepatch
|
28 | 29 |
|
29 | 30 |
|
@@ -67,5 +68,27 @@ def test_patch(self):
|
67 | 68 | self.assertEqual(expected_patch, makepatch(orig, mod), msg=msg)
|
68 | 69 |
|
69 | 70 |
|
| 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 | + |
70 | 93 | if __name__ == '__main__':
|
71 | 94 | unittest.main()
|
0 commit comments