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