Test case for build_query
diff --git a/tests/test_model.py b/tests/test_model.py
index d24c367..7f1cfd3 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -1,3 +1,4 @@
+# -*- coding:utf-8 -*-
#!/usr/bin/python2.4
#
# Copyright 2014 Google Inc. All Rights Reserved.
@@ -21,9 +22,9 @@
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
-import httplib2
import unittest
+from googleapiclient.model import BaseModel
from googleapiclient.model import makepatch
@@ -67,5 +68,27 @@
self.assertEqual(expected_patch, makepatch(orig, mod), msg=msg)
+class TestBaseModel(unittest.TestCase):
+ def test_build_query(self):
+ model = BaseModel()
+
+ test_cases = [
+ ('hello', 'world', '?hello=world'),
+ ('hello', u'world', '?hello=world'),
+ ('hello', '세계', '?hello=%EC%84%B8%EA%B3%84'),
+ ('hello', u'세계', '?hello=%EC%84%B8%EA%B3%84'),
+ ('hello', 'こんにちは', '?hello=%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF'),
+ ('hello', u'こんにちは', '?hello=%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF'),
+ ('hello', '你好', '?hello=%E4%BD%A0%E5%A5%BD'),
+ ('hello', u'你好', '?hello=%E4%BD%A0%E5%A5%BD'),
+ ('hello', 'مرحبا', '?hello=%D9%85%D8%B1%D8%AD%D8%A8%D8%A7'),
+ ('hello', u'مرحبا', '?hello=%D9%85%D8%B1%D8%AD%D8%A8%D8%A7')
+ ]
+
+ for case in test_cases:
+ key, value, expect = case
+ self.assertEqual(expect, model._build_query({key: value}))
+
+
if __name__ == '__main__':
unittest.main()