• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="ascii"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3          "DTD/xhtml1-transitional.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5<head>
6  <title>googleapiclient.http.RequestMockBuilder</title>
7  <link rel="stylesheet" href="epydoc.css" type="text/css" />
8  <script type="text/javascript" src="epydoc.js"></script>
9</head>
10
11<body bgcolor="white" text="black" link="blue" vlink="#204080"
12      alink="#204080">
13<!-- ==================== NAVIGATION BAR ==================== -->
14<table class="navbar" border="0" width="100%" cellpadding="0"
15       bgcolor="#a0c0ff" cellspacing="0">
16  <tr valign="middle">
17  <!-- Home link -->
18      <th>&nbsp;&nbsp;&nbsp;<a
19        href="googleapiclient-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
20
21  <!-- Tree link -->
22      <th>&nbsp;&nbsp;&nbsp;<a
23        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
24
25  <!-- Index link -->
26      <th>&nbsp;&nbsp;&nbsp;<a
27        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
28
29  <!-- Help link -->
30      <th>&nbsp;&nbsp;&nbsp;<a
31        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
32
33      <th class="navbar" width="100%"></th>
34  </tr>
35</table>
36<table width="100%" cellpadding="0" cellspacing="0">
37  <tr valign="top">
38    <td width="100%">
39      <span class="breadcrumbs">
40        <a href="googleapiclient-module.html">Package&nbsp;googleapiclient</a> ::
41        <a href="googleapiclient.http-module.html">Module&nbsp;http</a> ::
42        Class&nbsp;RequestMockBuilder
43      </span>
44    </td>
45    <td>
46      <table cellpadding="0" cellspacing="0">
47        <!-- hide/show private -->
48        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
49    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
50        <tr><td align="right"><span class="options"
51            >[<a href="frames.html" target="_top">frames</a
52            >]&nbsp;|&nbsp;<a href="googleapiclient.http.RequestMockBuilder-class.html"
53            target="_top">no&nbsp;frames</a>]</span></td></tr>
54      </table>
55    </td>
56  </tr>
57</table>
58<!-- ==================== CLASS DESCRIPTION ==================== -->
59<h1 class="epydoc">Class RequestMockBuilder</h1><p class="nomargin-top"><span class="codelink"><a href="googleapiclient.http-pysrc.html#RequestMockBuilder">source&nbsp;code</a></span></p>
60<center>
61<center>  <map id="uml_class_diagram_for_googleap_36" name="uml_class_diagram_for_googleap_36">
62<area shape="rect" id="node1_2" href="googleapiclient.http.RequestMockBuilder-class.html#__init__" title="Constructor for RequestMockBuilder" alt="" coords="17,38,679,58"/>
63<area shape="rect" id="node1_3" href="googleapiclient.http.RequestMockBuilder-class.html#__call__" title="Implements the callable interface that discovery.build() expects of requestBuilder, which is to build an object compatible with HttpRequest.execute()." alt="" coords="17,58,679,78"/>
64<area shape="rect" id="node1" href="googleapiclient.http.RequestMockBuilder-class.html" title="A simple mock of HttpRequest" alt="" coords="5,5,691,84"/>
65</map>
66  <img src="uml_class_diagram_for_googleap_36.gif" alt='' usemap="#uml_class_diagram_for_googleap_36" ismap="ismap" class="graph-without-title" />
67</center>
68</center>
69<hr />
70<pre class="literalblock">
71A simple mock of HttpRequest
72
73Pass in a dictionary to the constructor that maps request methodIds to
74tuples of (httplib2.Response, content, opt_expected_body) that should be
75returned when that method is called. None may also be passed in for the
76httplib2.Response, in which case a 200 OK response will be generated.
77If an opt_expected_body (str or dict) is provided, it will be compared to
78the body and UnexpectedBodyError will be raised on inequality.
79
80Example:
81  response = '{&quot;data&quot;: {&quot;id&quot;: &quot;tag:google.c...'
82  requestBuilder = RequestMockBuilder(
83    {
84      'plus.activities.get': (None, response),
85    }
86  )
87  googleapiclient.discovery.build(&quot;plus&quot;, &quot;v1&quot;, requestBuilder=requestBuilder)
88
89Methods that you do not supply a response for will return a
90200 OK with an empty string as the response content or raise an excpetion
91if check_unexpected is set to True. The methodId is taken from the rpcName
92in the discovery document.
93
94For more details see the project wiki.
95
96</pre>
97
98<!-- ==================== INSTANCE METHODS ==================== -->
99<a name="section-InstanceMethods"></a>
100<table class="summary" border="1" cellpadding="3"
101       cellspacing="0" width="100%" bgcolor="white">
102<tr bgcolor="#70b0f0" class="table-header">
103  <td colspan="2" class="table-header">
104    <table border="0" cellpadding="0" cellspacing="0" width="100%">
105      <tr valign="top">
106        <td align="left"><span class="table-header">Instance Methods</span></td>
107        <td align="right" valign="top"
108         ><span class="options">[<a href="#section-InstanceMethods"
109         class="privatelink" onclick="toggle_private();"
110         >hide private</a>]</span></td>
111      </tr>
112    </table>
113  </td>
114</tr>
115<tr>
116    <td width="15%" align="right" valign="top" class="summary">
117      <span class="summary-type">&nbsp;</span>
118    </td><td class="summary">
119      <table width="100%" cellpadding="0" cellspacing="0" border="0">
120        <tr>
121          <td><span class="summary-sig"><a href="googleapiclient.http.RequestMockBuilder-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
122        <span class="summary-sig-arg">responses</span>,
123        <span class="summary-sig-arg">check_unexpected</span>=<span class="summary-sig-default">False</span>)</span><br />
124      Constructor for RequestMockBuilder</td>
125          <td align="right" valign="top">
126            <span class="codelink"><a href="googleapiclient.http-pysrc.html#RequestMockBuilder.__init__">source&nbsp;code</a></span>
127
128          </td>
129        </tr>
130      </table>
131
132    </td>
133  </tr>
134<tr>
135    <td width="15%" align="right" valign="top" class="summary">
136      <span class="summary-type">&nbsp;</span>
137    </td><td class="summary">
138      <table width="100%" cellpadding="0" cellspacing="0" border="0">
139        <tr>
140          <td><span class="summary-sig"><a href="googleapiclient.http.RequestMockBuilder-class.html#__call__" class="summary-sig-name">__call__</a>(<span class="summary-sig-arg">self</span>,
141        <span class="summary-sig-arg">http</span>,
142        <span class="summary-sig-arg">postproc</span>,
143        <span class="summary-sig-arg">uri</span>,
144        <span class="summary-sig-arg">method</span>=<span class="summary-sig-default">'GET'</span>,
145        <span class="summary-sig-arg">body</span>=<span class="summary-sig-default">None</span>,
146        <span class="summary-sig-arg">headers</span>=<span class="summary-sig-default">None</span>,
147        <span class="summary-sig-arg">methodId</span>=<span class="summary-sig-default">None</span>,
148        <span class="summary-sig-arg">resumable</span>=<span class="summary-sig-default">None</span>)</span><br />
149      Implements the callable interface that discovery.build() expects
150of requestBuilder, which is to build an object compatible with
151HttpRequest.execute().</td>
152          <td align="right" valign="top">
153            <span class="codelink"><a href="googleapiclient.http-pysrc.html#RequestMockBuilder.__call__">source&nbsp;code</a></span>
154
155          </td>
156        </tr>
157      </table>
158
159    </td>
160  </tr>
161  <tr>
162    <td colspan="2" class="summary">
163    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
164      <code>__delattr__</code>,
165      <code>__format__</code>,
166      <code>__getattribute__</code>,
167      <code>__hash__</code>,
168      <code>__new__</code>,
169      <code>__reduce__</code>,
170      <code>__reduce_ex__</code>,
171      <code>__repr__</code>,
172      <code>__setattr__</code>,
173      <code>__sizeof__</code>,
174      <code>__str__</code>,
175      <code>__subclasshook__</code>
176      </p>
177    </td>
178  </tr>
179</table>
180<!-- ==================== PROPERTIES ==================== -->
181<a name="section-Properties"></a>
182<table class="summary" border="1" cellpadding="3"
183       cellspacing="0" width="100%" bgcolor="white">
184<tr bgcolor="#70b0f0" class="table-header">
185  <td colspan="2" class="table-header">
186    <table border="0" cellpadding="0" cellspacing="0" width="100%">
187      <tr valign="top">
188        <td align="left"><span class="table-header">Properties</span></td>
189        <td align="right" valign="top"
190         ><span class="options">[<a href="#section-Properties"
191         class="privatelink" onclick="toggle_private();"
192         >hide private</a>]</span></td>
193      </tr>
194    </table>
195  </td>
196</tr>
197  <tr>
198    <td colspan="2" class="summary">
199    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
200      <code>__class__</code>
201      </p>
202    </td>
203  </tr>
204</table>
205<!-- ==================== METHOD DETAILS ==================== -->
206<a name="section-MethodDetails"></a>
207<table class="details" border="1" cellpadding="3"
208       cellspacing="0" width="100%" bgcolor="white">
209<tr bgcolor="#70b0f0" class="table-header">
210  <td colspan="2" class="table-header">
211    <table border="0" cellpadding="0" cellspacing="0" width="100%">
212      <tr valign="top">
213        <td align="left"><span class="table-header">Method Details</span></td>
214        <td align="right" valign="top"
215         ><span class="options">[<a href="#section-MethodDetails"
216         class="privatelink" onclick="toggle_private();"
217         >hide private</a>]</span></td>
218      </tr>
219    </table>
220  </td>
221</tr>
222</table>
223<a name="__init__"></a>
224<div>
225<table class="details" border="1" cellpadding="3"
226       cellspacing="0" width="100%" bgcolor="white">
227<tr><td>
228  <table width="100%" cellpadding="0" cellspacing="0" border="0">
229  <tr valign="top"><td>
230  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
231        <span class="sig-arg">responses</span>,
232        <span class="sig-arg">check_unexpected</span>=<span class="sig-default">False</span>)</span>
233    <br /><em class="fname">(Constructor)</em>
234  </h3>
235  </td><td align="right" valign="top"
236    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#RequestMockBuilder.__init__">source&nbsp;code</a></span>&nbsp;
237    </td>
238  </tr></table>
239
240  <pre class="literalblock">
241Constructor for RequestMockBuilder
242
243The constructed object should be a callable object
244that can replace the class HttpResponse.
245
246responses - A dictionary that maps methodIds into tuples
247            of (httplib2.Response, content). The methodId
248            comes from the 'rpcName' field in the discovery
249            document.
250check_unexpected - A boolean setting whether or not UnexpectedMethodError
251                   should be raised on unsupplied method.
252
253</pre>
254  <dl class="fields">
255    <dt>Overrides:
256        object.__init__
257    </dt>
258  </dl>
259</td></tr></table>
260</div>
261<a name="__call__"></a>
262<div>
263<table class="details" border="1" cellpadding="3"
264       cellspacing="0" width="100%" bgcolor="white">
265<tr><td>
266  <table width="100%" cellpadding="0" cellspacing="0" border="0">
267  <tr valign="top"><td>
268  <h3 class="epydoc"><span class="sig"><span class="sig-name">__call__</span>(<span class="sig-arg">self</span>,
269        <span class="sig-arg">http</span>,
270        <span class="sig-arg">postproc</span>,
271        <span class="sig-arg">uri</span>,
272        <span class="sig-arg">method</span>=<span class="sig-default">'GET'</span>,
273        <span class="sig-arg">body</span>=<span class="sig-default">None</span>,
274        <span class="sig-arg">headers</span>=<span class="sig-default">None</span>,
275        <span class="sig-arg">methodId</span>=<span class="sig-default">None</span>,
276        <span class="sig-arg">resumable</span>=<span class="sig-default">None</span>)</span>
277    <br /><em class="fname">(Call operator)</em>
278  </h3>
279  </td><td align="right" valign="top"
280    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#RequestMockBuilder.__call__">source&nbsp;code</a></span>&nbsp;
281    </td>
282  </tr></table>
283
284  <pre class="literalblock">
285Implements the callable interface that discovery.build() expects
286of requestBuilder, which is to build an object compatible with
287HttpRequest.execute(). See that method for the description of the
288parameters and the expected response.
289
290</pre>
291  <dl class="fields">
292  </dl>
293</td></tr></table>
294</div>
295<br />
296<!-- ==================== NAVIGATION BAR ==================== -->
297<table class="navbar" border="0" width="100%" cellpadding="0"
298       bgcolor="#a0c0ff" cellspacing="0">
299  <tr valign="middle">
300  <!-- Home link -->
301      <th>&nbsp;&nbsp;&nbsp;<a
302        href="googleapiclient-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
303
304  <!-- Tree link -->
305      <th>&nbsp;&nbsp;&nbsp;<a
306        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
307
308  <!-- Index link -->
309      <th>&nbsp;&nbsp;&nbsp;<a
310        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
311
312  <!-- Help link -->
313      <th>&nbsp;&nbsp;&nbsp;<a
314        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
315
316      <th class="navbar" width="100%"></th>
317  </tr>
318</table>
319<table border="0" cellpadding="0" cellspacing="0" width="100%%">
320  <tr>
321    <td align="left" class="footer">
322    Generated by Epydoc 3.0.1 on Fri Jun 14 15:57:28 2019
323    </td>
324    <td align="right" class="footer">
325      <a target="mainFrame" href="http://epydoc.sourceforge.net"
326        >http://epydoc.sourceforge.net</a>
327    </td>
328  </tr>
329</table>
330
331<script type="text/javascript">
332  <!--
333  // Private objects are initially displayed (because if
334  // javascript is turned off then we want them to be
335  // visible); but by default, we want to hide them.  So hide
336  // them unless we have a cookie that says to show them.
337  checkCookie();
338  // -->
339</script>
340</body>
341</html>
342