blob: 7b95d58156fa49ab6b667194194e4a8f146cf0d4 [file] [log] [blame]
Joe Gregorioba9ea7f2010-08-19 15:49:04 -04001#!/usr/bin/python2.4
2#
3# Copyright 2010 Google Inc. All Rights Reserved.
4
5"""Discovery document tests
6
7Unit tests for objects created from discovery documents.
8"""
9
10__author__ = 'jcgregorio@google.com (Joe Gregorio)'
11
12from apiclient.discovery import JsonModel
13import os
14import unittest
15
16
17class Model(unittest.TestCase):
18 def test_json_no_body(self):
19 model = JsonModel()
20
21 headers = {}
ade@google.com850cf552010-08-20 23:24:56 +010022 path_params = {}
23 query_params = {}
24 body = None
Joe Gregorioba9ea7f2010-08-19 15:49:04 -040025
ade@google.com850cf552010-08-20 23:24:56 +010026 headers, params, query, body = model.request(headers, path_params, query_params, body)
Joe Gregorioba9ea7f2010-08-19 15:49:04 -040027
28 self.assertEqual(headers['accept'], 'application/json')
29 self.assertTrue('content-type' not in headers)
30 self.assertNotEqual(query, '')
31 self.assertEqual(body, None)
32
33 def test_json_body(self):
34 model = JsonModel()
35
36 headers = {}
ade@google.com850cf552010-08-20 23:24:56 +010037 path_params = {}
38 query_params = {}
39 body = {}
Joe Gregorioba9ea7f2010-08-19 15:49:04 -040040
ade@google.com850cf552010-08-20 23:24:56 +010041 headers, params, query, body = model.request(headers, path_params, query_params, body)
Joe Gregorioba9ea7f2010-08-19 15:49:04 -040042
43 self.assertEqual(headers['accept'], 'application/json')
44 self.assertEqual(headers['content-type'], 'application/json')
45 self.assertNotEqual(query, '')
46 self.assertEqual(body, '{"data": {}}')
47
48if __name__ == '__main__':
49 unittest.main()