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.HttpMockSequence</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> <a 19 href="googleapiclient-module.html">Home</a> </th> 20 21 <!-- Tree link --> 22 <th> <a 23 href="module-tree.html">Trees</a> </th> 24 25 <!-- Index link --> 26 <th> <a 27 href="identifier-index.html">Indices</a> </th> 28 29 <!-- Help link --> 30 <th> <a 31 href="help.html">Help</a> </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 googleapiclient</a> :: 41 <a href="googleapiclient.http-module.html">Module http</a> :: 42 Class HttpMockSequence 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 private</a>]</span></td></tr> 50 <tr><td align="right"><span class="options" 51 >[<a href="frames.html" target="_top">frames</a 52 >] | <a href="googleapiclient.http.HttpMockSequence-class.html" 53 target="_top">no frames</a>]</span></td></tr> 54 </table> 55 </td> 56 </tr> 57</table> 58<!-- ==================== CLASS DESCRIPTION ==================== --> 59<h1 class="epydoc">Class HttpMockSequence</h1><p class="nomargin-top"><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpMockSequence">source code</a></span></p> 60<center> 61<center> <map id="uml_class_diagram_for_googleap_26" name="uml_class_diagram_for_googleap_26"> 62<area shape="rect" id="node1_2" href="googleapiclient.http.HttpMockSequence-class.html#__init__" title="Args:..." alt="" coords="17,38,609,58"/> 63<area shape="rect" id="node1_3" href="googleapiclient.http.HttpMockSequence-class.html#request" title="googleapiclient.http.HttpMockSequence.request" alt="" coords="17,58,609,78"/> 64<area shape="rect" id="node1" href="googleapiclient.http.HttpMockSequence-class.html" title="Mock of httplib2.Http" alt="" coords="5,5,621,84"/> 65</map> 66 <img src="uml_class_diagram_for_googleap_26.gif" alt='' usemap="#uml_class_diagram_for_googleap_26" ismap="ismap" class="graph-without-title" /> 67</center> 68</center> 69<hr /> 70<pre class="literalblock"> 71Mock of httplib2.Http 72 73Mocks a sequence of calls to request returning different responses for each 74call. Create an instance initialized with the desired response headers 75and content and then use as if an httplib2.Http instance. 76 77 http = HttpMockSequence([ 78 ({'status': '401'}, ''), 79 ({'status': '200'}, '{"access_token":"1/3w","expires_in":3600}'), 80 ({'status': '200'}, 'echo_request_headers'), 81 ]) 82 resp, content = http.request("http://examples.com") 83 84There are special values you can pass in for content to trigger 85behavours that are helpful in testing. 86 87'echo_request_headers' means return the request headers in the response body 88'echo_request_headers_as_json' means return the request headers in 89 the response body 90'echo_request_body' means return the request body in the response body 91'echo_request_uri' means return the request uri in the response body 92 93</pre> 94 95<!-- ==================== INSTANCE METHODS ==================== --> 96<a name="section-InstanceMethods"></a> 97<table class="summary" border="1" cellpadding="3" 98 cellspacing="0" width="100%" bgcolor="white"> 99<tr bgcolor="#70b0f0" class="table-header"> 100 <td colspan="2" class="table-header"> 101 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 102 <tr valign="top"> 103 <td align="left"><span class="table-header">Instance Methods</span></td> 104 <td align="right" valign="top" 105 ><span class="options">[<a href="#section-InstanceMethods" 106 class="privatelink" onclick="toggle_private();" 107 >hide private</a>]</span></td> 108 </tr> 109 </table> 110 </td> 111</tr> 112<tr> 113 <td width="15%" align="right" valign="top" class="summary"> 114 <span class="summary-type"> </span> 115 </td><td class="summary"> 116 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 117 <tr> 118 <td><span class="summary-sig"><a href="googleapiclient.http.HttpMockSequence-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>, 119 <span class="summary-sig-arg">iterable</span>)</span><br /> 120 Args:...</td> 121 <td align="right" valign="top"> 122 <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpMockSequence.__init__">source code</a></span> 123 124 </td> 125 </tr> 126 </table> 127 128 </td> 129 </tr> 130<tr> 131 <td width="15%" align="right" valign="top" class="summary"> 132 <span class="summary-type"> </span> 133 </td><td class="summary"> 134 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 135 <tr> 136 <td><span class="summary-sig"><a name="request"></a><span class="summary-sig-name">request</span>(<span class="summary-sig-arg">self</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">redirections</span>=<span class="summary-sig-default">1</span>, 142 <span class="summary-sig-arg">connection_type</span>=<span class="summary-sig-default">None</span>)</span></td> 143 <td align="right" valign="top"> 144 <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpMockSequence.request">source code</a></span> 145 146 </td> 147 </tr> 148 </table> 149 150 </td> 151 </tr> 152 <tr> 153 <td colspan="2" class="summary"> 154 <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: 155 <code>__delattr__</code>, 156 <code>__format__</code>, 157 <code>__getattribute__</code>, 158 <code>__hash__</code>, 159 <code>__new__</code>, 160 <code>__reduce__</code>, 161 <code>__reduce_ex__</code>, 162 <code>__repr__</code>, 163 <code>__setattr__</code>, 164 <code>__sizeof__</code>, 165 <code>__str__</code>, 166 <code>__subclasshook__</code> 167 </p> 168 </td> 169 </tr> 170</table> 171<!-- ==================== PROPERTIES ==================== --> 172<a name="section-Properties"></a> 173<table class="summary" border="1" cellpadding="3" 174 cellspacing="0" width="100%" bgcolor="white"> 175<tr bgcolor="#70b0f0" class="table-header"> 176 <td colspan="2" class="table-header"> 177 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 178 <tr valign="top"> 179 <td align="left"><span class="table-header">Properties</span></td> 180 <td align="right" valign="top" 181 ><span class="options">[<a href="#section-Properties" 182 class="privatelink" onclick="toggle_private();" 183 >hide private</a>]</span></td> 184 </tr> 185 </table> 186 </td> 187</tr> 188 <tr> 189 <td colspan="2" class="summary"> 190 <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: 191 <code>__class__</code> 192 </p> 193 </td> 194 </tr> 195</table> 196<!-- ==================== METHOD DETAILS ==================== --> 197<a name="section-MethodDetails"></a> 198<table class="details" border="1" cellpadding="3" 199 cellspacing="0" width="100%" bgcolor="white"> 200<tr bgcolor="#70b0f0" class="table-header"> 201 <td colspan="2" class="table-header"> 202 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 203 <tr valign="top"> 204 <td align="left"><span class="table-header">Method Details</span></td> 205 <td align="right" valign="top" 206 ><span class="options">[<a href="#section-MethodDetails" 207 class="privatelink" onclick="toggle_private();" 208 >hide private</a>]</span></td> 209 </tr> 210 </table> 211 </td> 212</tr> 213</table> 214<a name="__init__"></a> 215<div> 216<table class="details" border="1" cellpadding="3" 217 cellspacing="0" width="100%" bgcolor="white"> 218<tr><td> 219 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 220 <tr valign="top"><td> 221 <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>, 222 <span class="sig-arg">iterable</span>)</span> 223 <br /><em class="fname">(Constructor)</em> 224 </h3> 225 </td><td align="right" valign="top" 226 ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpMockSequence.__init__">source code</a></span> 227 </td> 228 </tr></table> 229 230 <pre class="literalblock"> 231 232Args: 233 iterable: iterable, a sequence of pairs of (headers, body) 234 235</pre> 236 <dl class="fields"> 237 <dt>Overrides: 238 object.__init__ 239 </dt> 240 </dl> 241</td></tr></table> 242</div> 243<br /> 244<!-- ==================== NAVIGATION BAR ==================== --> 245<table class="navbar" border="0" width="100%" cellpadding="0" 246 bgcolor="#a0c0ff" cellspacing="0"> 247 <tr valign="middle"> 248 <!-- Home link --> 249 <th> <a 250 href="googleapiclient-module.html">Home</a> </th> 251 252 <!-- Tree link --> 253 <th> <a 254 href="module-tree.html">Trees</a> </th> 255 256 <!-- Index link --> 257 <th> <a 258 href="identifier-index.html">Indices</a> </th> 259 260 <!-- Help link --> 261 <th> <a 262 href="help.html">Help</a> </th> 263 264 <th class="navbar" width="100%"></th> 265 </tr> 266</table> 267<table border="0" cellpadding="0" cellspacing="0" width="100%%"> 268 <tr> 269 <td align="left" class="footer"> 270 Generated by Epydoc 3.0.1 on Fri Jun 14 15:57:28 2019 271 </td> 272 <td align="right" class="footer"> 273 <a target="mainFrame" href="http://epydoc.sourceforge.net" 274 >http://epydoc.sourceforge.net</a> 275 </td> 276 </tr> 277</table> 278 279<script type="text/javascript"> 280 <!-- 281 // Private objects are initially displayed (because if 282 // javascript is turned off then we want them to be 283 // visible); but by default, we want to hide them. So hide 284 // them unless we have a cookie that says to show them. 285 checkCookie(); 286 // --> 287</script> 288</body> 289</html> 290