service.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>grpc.framework.face.testing.service &mdash; grpcio 0.10.0a0 documentation</title>
  8. <link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
  9. <link rel="top" title="grpcio 0.10.0a0 documentation" href="../../../../../index.html"/>
  10. <link rel="up" title="Module code" href="../../../../index.html"/>
  11. <script src="_static/js/modernizr.min.js"></script>
  12. </head>
  13. <body class="wy-body-for-nav" role="document">
  14. <div class="wy-grid-for-nav">
  15. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  16. <div class="wy-side-nav-search">
  17. <a href="../../../../../index.html" class="icon icon-home"> grpcio
  18. </a>
  19. <div role="search">
  20. <form id="rtd-search-form" class="wy-form" action="../../../../../search.html" method="get">
  21. <input type="text" name="q" placeholder="Search docs" />
  22. <input type="hidden" name="check_keywords" value="yes" />
  23. <input type="hidden" name="area" value="default" />
  24. </form>
  25. </div>
  26. </div>
  27. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  28. <ul>
  29. <li class="toctree-l1"><a class="reference internal" href="../../../../../grpc.html">grpc package</a><ul>
  30. <li class="toctree-l2"><a class="reference internal" href="../../../../../grpc.html#subpackages">Subpackages</a><ul>
  31. <li class="toctree-l3"><a class="reference internal" href="../../../../../grpc.early_adopter.html">grpc.early_adopter package</a><ul>
  32. <li class="toctree-l4"><a class="reference internal" href="../../../../../grpc.early_adopter.html#submodules">Submodules</a></li>
  33. <li class="toctree-l4"><a class="reference internal" href="../../../../../grpc.early_adopter.html#module-grpc.early_adopter.implementations">grpc.early_adopter.implementations module</a></li>
  34. <li class="toctree-l4"><a class="reference internal" href="../../../../../grpc.early_adopter.html#module-grpc.early_adopter.implementations_test">grpc.early_adopter.implementations_test module</a></li>
  35. <li class="toctree-l4"><a class="reference internal" href="../../../../../grpc.early_adopter.html#module-grpc.early_adopter">Module contents</a></li>
  36. </ul>
  37. </li>
  38. <li class="toctree-l3"><a class="reference internal" href="../../../../../grpc.framework.html">grpc.framework package</a><ul>
  39. <li class="toctree-l4"><a class="reference internal" href="../../../../../grpc.framework.html#subpackages">Subpackages</a></li>
  40. <li class="toctree-l4"><a class="reference internal" href="../../../../../grpc.framework.html#module-grpc.framework">Module contents</a></li>
  41. </ul>
  42. </li>
  43. </ul>
  44. </li>
  45. <li class="toctree-l2"><a class="reference internal" href="../../../../../grpc.html#module-grpc">Module contents</a></li>
  46. </ul>
  47. </li>
  48. </ul>
  49. </div>
  50. &nbsp;
  51. </nav>
  52. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  53. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  54. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  55. <a href="../../../../../index.html">grpcio</a>
  56. </nav>
  57. <div class="wy-nav-content">
  58. <div class="rst-content">
  59. <div role="navigation" aria-label="breadcrumbs navigation">
  60. <ul class="wy-breadcrumbs">
  61. <li><a href="../../../../../index.html">Docs</a> &raquo;</li>
  62. <li><a href="../../../../index.html">Module code</a> &raquo;</li>
  63. <li>grpc.framework.face.testing.service</li>
  64. <li class="wy-breadcrumbs-aside">
  65. </li>
  66. </ul>
  67. <hr/>
  68. </div>
  69. <div role="main" class="document">
  70. <h1>Source code for grpc.framework.face.testing.service</h1><div class="highlight"><pre>
  71. <span class="c"># Copyright 2015, Google Inc.</span>
  72. <span class="c"># All rights reserved.</span>
  73. <span class="c">#</span>
  74. <span class="c"># Redistribution and use in source and binary forms, with or without</span>
  75. <span class="c"># modification, are permitted provided that the following conditions are</span>
  76. <span class="c"># met:</span>
  77. <span class="c">#</span>
  78. <span class="c"># * Redistributions of source code must retain the above copyright</span>
  79. <span class="c"># notice, this list of conditions and the following disclaimer.</span>
  80. <span class="c"># * Redistributions in binary form must reproduce the above</span>
  81. <span class="c"># copyright notice, this list of conditions and the following disclaimer</span>
  82. <span class="c"># in the documentation and/or other materials provided with the</span>
  83. <span class="c"># distribution.</span>
  84. <span class="c"># * Neither the name of Google Inc. nor the names of its</span>
  85. <span class="c"># contributors may be used to endorse or promote products derived from</span>
  86. <span class="c"># this software without specific prior written permission.</span>
  87. <span class="c">#</span>
  88. <span class="c"># THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
  89. <span class="c"># &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
  90. <span class="c"># LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
  91. <span class="c"># A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span>
  92. <span class="c"># OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
  93. <span class="c"># SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
  94. <span class="c"># LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span>
  95. <span class="c"># DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span>
  96. <span class="c"># THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
  97. <span class="c"># (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span>
  98. <span class="c"># OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
  99. <span class="sd">&quot;&quot;&quot;Private interfaces implemented by data sets used in Face-layer tests.&quot;&quot;&quot;</span>
  100. <span class="kn">import</span> <span class="nn">abc</span>
  101. <span class="c"># interfaces is referenced from specification in this module.</span>
  102. <span class="kn">from</span> <span class="nn">grpc.framework.face</span> <span class="kn">import</span> <span class="n">interfaces</span> <span class="k">as</span> <span class="n">face_interfaces</span> <span class="c"># pylint: disable=unused-import</span>
  103. <span class="kn">from</span> <span class="nn">grpc.framework.face.testing</span> <span class="kn">import</span> <span class="n">interfaces</span>
  104. <div class="viewcode-block" id="UnaryUnaryTestMethodImplementation"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.UnaryUnaryTestMethodImplementation">[docs]</a><span class="k">class</span> <span class="nc">UnaryUnaryTestMethodImplementation</span><span class="p">(</span><span class="n">interfaces</span><span class="o">.</span><span class="n">Method</span><span class="p">):</span>
  105. <span class="sd">&quot;&quot;&quot;A controllable implementation of a unary-unary RPC method.&quot;&quot;&quot;</span>
  106. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span>
  107. <span class="nd">@abc.abstractmethod</span>
  108. <div class="viewcode-block" id="UnaryUnaryTestMethodImplementation.service"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.UnaryUnaryTestMethodImplementation.service">[docs]</a> <span class="k">def</span> <span class="nf">service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">response_callback</span><span class="p">,</span> <span class="n">context</span><span class="p">,</span> <span class="n">control</span><span class="p">):</span>
  109. <span class="sd">&quot;&quot;&quot;Services an RPC that accepts one message and produces one message.</span>
  110. <span class="sd"> Args:</span>
  111. <span class="sd"> request: The single request message for the RPC.</span>
  112. <span class="sd"> response_callback: A callback to be called to accept the response message</span>
  113. <span class="sd"> of the RPC.</span>
  114. <span class="sd"> context: An face_interfaces.RpcContext object.</span>
  115. <span class="sd"> control: A test_control.Control to control execution of this method.</span>
  116. <span class="sd"> Raises:</span>
  117. <span class="sd"> abandonment.Abandoned: May or may not be raised when the RPC has been</span>
  118. <span class="sd"> aborted.</span>
  119. <span class="sd"> &quot;&quot;&quot;</span>
  120. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  121. </div></div>
  122. <div class="viewcode-block" id="UnaryUnaryTestMessages"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.UnaryUnaryTestMessages">[docs]</a><span class="k">class</span> <span class="nc">UnaryUnaryTestMessages</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
  123. <span class="sd">&quot;&quot;&quot;A type for unary-request-unary-response message pairings.&quot;&quot;&quot;</span>
  124. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span>
  125. <span class="nd">@abc.abstractmethod</span>
  126. <div class="viewcode-block" id="UnaryUnaryTestMessages.request"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.UnaryUnaryTestMessages.request">[docs]</a> <span class="k">def</span> <span class="nf">request</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  127. <span class="sd">&quot;&quot;&quot;Affords a request message.</span>
  128. <span class="sd"> Implementations of this method should return a different message with each</span>
  129. <span class="sd"> call so that multiple test executions of the test method may be made with</span>
  130. <span class="sd"> different inputs.</span>
  131. <span class="sd"> Returns:</span>
  132. <span class="sd"> A request message.</span>
  133. <span class="sd"> &quot;&quot;&quot;</span>
  134. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  135. </div>
  136. <span class="nd">@abc.abstractmethod</span>
  137. <div class="viewcode-block" id="UnaryUnaryTestMessages.verify"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.UnaryUnaryTestMessages.verify">[docs]</a> <span class="k">def</span> <span class="nf">verify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">response</span><span class="p">,</span> <span class="n">test_case</span><span class="p">):</span>
  138. <span class="sd">&quot;&quot;&quot;Verifies that the computed response matches the given request.</span>
  139. <span class="sd"> Args:</span>
  140. <span class="sd"> request: A request message.</span>
  141. <span class="sd"> response: A response message.</span>
  142. <span class="sd"> test_case: A unittest.TestCase object affording useful assertion methods.</span>
  143. <span class="sd"> Raises:</span>
  144. <span class="sd"> AssertionError: If the request and response do not match, indicating that</span>
  145. <span class="sd"> there was some problem executing the RPC under test.</span>
  146. <span class="sd"> &quot;&quot;&quot;</span>
  147. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  148. </div></div>
  149. <div class="viewcode-block" id="UnaryStreamTestMethodImplementation"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.UnaryStreamTestMethodImplementation">[docs]</a><span class="k">class</span> <span class="nc">UnaryStreamTestMethodImplementation</span><span class="p">(</span><span class="n">interfaces</span><span class="o">.</span><span class="n">Method</span><span class="p">):</span>
  150. <span class="sd">&quot;&quot;&quot;A controllable implementation of a unary-stream RPC method.&quot;&quot;&quot;</span>
  151. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span>
  152. <span class="nd">@abc.abstractmethod</span>
  153. <div class="viewcode-block" id="UnaryStreamTestMethodImplementation.service"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.UnaryStreamTestMethodImplementation.service">[docs]</a> <span class="k">def</span> <span class="nf">service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">response_consumer</span><span class="p">,</span> <span class="n">context</span><span class="p">,</span> <span class="n">control</span><span class="p">):</span>
  154. <span class="sd">&quot;&quot;&quot;Services an RPC that takes one message and produces a stream of messages.</span>
  155. <span class="sd"> Args:</span>
  156. <span class="sd"> request: The single request message for the RPC.</span>
  157. <span class="sd"> response_consumer: A stream.Consumer to be called to accept the response</span>
  158. <span class="sd"> messages of the RPC.</span>
  159. <span class="sd"> context: A face_interfaces.RpcContext object.</span>
  160. <span class="sd"> control: A test_control.Control to control execution of this method.</span>
  161. <span class="sd"> Raises:</span>
  162. <span class="sd"> abandonment.Abandoned: May or may not be raised when the RPC has been</span>
  163. <span class="sd"> aborted.</span>
  164. <span class="sd"> &quot;&quot;&quot;</span>
  165. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  166. </div></div>
  167. <div class="viewcode-block" id="UnaryStreamTestMessages"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.UnaryStreamTestMessages">[docs]</a><span class="k">class</span> <span class="nc">UnaryStreamTestMessages</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
  168. <span class="sd">&quot;&quot;&quot;A type for unary-request-stream-response message pairings.&quot;&quot;&quot;</span>
  169. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span>
  170. <span class="nd">@abc.abstractmethod</span>
  171. <div class="viewcode-block" id="UnaryStreamTestMessages.request"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.UnaryStreamTestMessages.request">[docs]</a> <span class="k">def</span> <span class="nf">request</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  172. <span class="sd">&quot;&quot;&quot;Affords a request message.</span>
  173. <span class="sd"> Implementations of this method should return a different message with each</span>
  174. <span class="sd"> call so that multiple test executions of the test method may be made with</span>
  175. <span class="sd"> different inputs.</span>
  176. <span class="sd"> Returns:</span>
  177. <span class="sd"> A request message.</span>
  178. <span class="sd"> &quot;&quot;&quot;</span>
  179. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  180. </div>
  181. <span class="nd">@abc.abstractmethod</span>
  182. <div class="viewcode-block" id="UnaryStreamTestMessages.verify"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.UnaryStreamTestMessages.verify">[docs]</a> <span class="k">def</span> <span class="nf">verify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">responses</span><span class="p">,</span> <span class="n">test_case</span><span class="p">):</span>
  183. <span class="sd">&quot;&quot;&quot;Verifies that the computed responses match the given request.</span>
  184. <span class="sd"> Args:</span>
  185. <span class="sd"> request: A request message.</span>
  186. <span class="sd"> responses: A sequence of response messages.</span>
  187. <span class="sd"> test_case: A unittest.TestCase object affording useful assertion methods.</span>
  188. <span class="sd"> Raises:</span>
  189. <span class="sd"> AssertionError: If the request and responses do not match, indicating that</span>
  190. <span class="sd"> there was some problem executing the RPC under test.</span>
  191. <span class="sd"> &quot;&quot;&quot;</span>
  192. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  193. </div></div>
  194. <div class="viewcode-block" id="StreamUnaryTestMethodImplementation"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.StreamUnaryTestMethodImplementation">[docs]</a><span class="k">class</span> <span class="nc">StreamUnaryTestMethodImplementation</span><span class="p">(</span><span class="n">interfaces</span><span class="o">.</span><span class="n">Method</span><span class="p">):</span>
  195. <span class="sd">&quot;&quot;&quot;A controllable implementation of a stream-unary RPC method.&quot;&quot;&quot;</span>
  196. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span>
  197. <span class="nd">@abc.abstractmethod</span>
  198. <div class="viewcode-block" id="StreamUnaryTestMethodImplementation.service"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.StreamUnaryTestMethodImplementation.service">[docs]</a> <span class="k">def</span> <span class="nf">service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">response_callback</span><span class="p">,</span> <span class="n">context</span><span class="p">,</span> <span class="n">control</span><span class="p">):</span>
  199. <span class="sd">&quot;&quot;&quot;Services an RPC that takes a stream of messages and produces one message.</span>
  200. <span class="sd"> Args:</span>
  201. <span class="sd"> response_callback: A callback to be called to accept the response message</span>
  202. <span class="sd"> of the RPC.</span>
  203. <span class="sd"> context: A face_interfaces.RpcContext object.</span>
  204. <span class="sd"> control: A test_control.Control to control execution of this method.</span>
  205. <span class="sd"> Returns:</span>
  206. <span class="sd"> A stream.Consumer with which to accept the request messages of the RPC.</span>
  207. <span class="sd"> The consumer returned from this method may or may not be invoked to</span>
  208. <span class="sd"> completion: in the case of RPC abortion, RPC Framework will simply stop</span>
  209. <span class="sd"> passing messages to this object. Implementations must not assume that</span>
  210. <span class="sd"> this object will be called to completion of the request stream or even</span>
  211. <span class="sd"> called at all.</span>
  212. <span class="sd"> Raises:</span>
  213. <span class="sd"> abandonment.Abandoned: May or may not be raised when the RPC has been</span>
  214. <span class="sd"> aborted.</span>
  215. <span class="sd"> &quot;&quot;&quot;</span>
  216. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  217. </div></div>
  218. <div class="viewcode-block" id="StreamUnaryTestMessages"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.StreamUnaryTestMessages">[docs]</a><span class="k">class</span> <span class="nc">StreamUnaryTestMessages</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
  219. <span class="sd">&quot;&quot;&quot;A type for stream-request-unary-response message pairings.&quot;&quot;&quot;</span>
  220. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span>
  221. <span class="nd">@abc.abstractmethod</span>
  222. <div class="viewcode-block" id="StreamUnaryTestMessages.requests"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.StreamUnaryTestMessages.requests">[docs]</a> <span class="k">def</span> <span class="nf">requests</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  223. <span class="sd">&quot;&quot;&quot;Affords a sequence of request messages.</span>
  224. <span class="sd"> Implementations of this method should return a different sequences with each</span>
  225. <span class="sd"> call so that multiple test executions of the test method may be made with</span>
  226. <span class="sd"> different inputs.</span>
  227. <span class="sd"> Returns:</span>
  228. <span class="sd"> A sequence of request messages.</span>
  229. <span class="sd"> &quot;&quot;&quot;</span>
  230. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  231. </div>
  232. <span class="nd">@abc.abstractmethod</span>
  233. <div class="viewcode-block" id="StreamUnaryTestMessages.verify"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.StreamUnaryTestMessages.verify">[docs]</a> <span class="k">def</span> <span class="nf">verify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">requests</span><span class="p">,</span> <span class="n">response</span><span class="p">,</span> <span class="n">test_case</span><span class="p">):</span>
  234. <span class="sd">&quot;&quot;&quot;Verifies that the computed response matches the given requests.</span>
  235. <span class="sd"> Args:</span>
  236. <span class="sd"> requests: A sequence of request messages.</span>
  237. <span class="sd"> response: A response message.</span>
  238. <span class="sd"> test_case: A unittest.TestCase object affording useful assertion methods.</span>
  239. <span class="sd"> Raises:</span>
  240. <span class="sd"> AssertionError: If the requests and response do not match, indicating that</span>
  241. <span class="sd"> there was some problem executing the RPC under test.</span>
  242. <span class="sd"> &quot;&quot;&quot;</span>
  243. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  244. </div></div>
  245. <div class="viewcode-block" id="StreamStreamTestMethodImplementation"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.StreamStreamTestMethodImplementation">[docs]</a><span class="k">class</span> <span class="nc">StreamStreamTestMethodImplementation</span><span class="p">(</span><span class="n">interfaces</span><span class="o">.</span><span class="n">Method</span><span class="p">):</span>
  246. <span class="sd">&quot;&quot;&quot;A controllable implementation of a stream-stream RPC method.&quot;&quot;&quot;</span>
  247. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span>
  248. <span class="nd">@abc.abstractmethod</span>
  249. <div class="viewcode-block" id="StreamStreamTestMethodImplementation.service"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.StreamStreamTestMethodImplementation.service">[docs]</a> <span class="k">def</span> <span class="nf">service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">response_consumer</span><span class="p">,</span> <span class="n">context</span><span class="p">,</span> <span class="n">control</span><span class="p">):</span>
  250. <span class="sd">&quot;&quot;&quot;Services an RPC that accepts and produces streams of messages.</span>
  251. <span class="sd"> Args:</span>
  252. <span class="sd"> response_consumer: A stream.Consumer to be called to accept the response</span>
  253. <span class="sd"> messages of the RPC.</span>
  254. <span class="sd"> context: A face_interfaces.RpcContext object.</span>
  255. <span class="sd"> control: A test_control.Control to control execution of this method.</span>
  256. <span class="sd"> Returns:</span>
  257. <span class="sd"> A stream.Consumer with which to accept the request messages of the RPC.</span>
  258. <span class="sd"> The consumer returned from this method may or may not be invoked to</span>
  259. <span class="sd"> completion: in the case of RPC abortion, RPC Framework will simply stop</span>
  260. <span class="sd"> passing messages to this object. Implementations must not assume that</span>
  261. <span class="sd"> this object will be called to completion of the request stream or even</span>
  262. <span class="sd"> called at all.</span>
  263. <span class="sd"> Raises:</span>
  264. <span class="sd"> abandonment.Abandoned: May or may not be raised when the RPC has been</span>
  265. <span class="sd"> aborted.</span>
  266. <span class="sd"> &quot;&quot;&quot;</span>
  267. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  268. </div></div>
  269. <div class="viewcode-block" id="StreamStreamTestMessages"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.StreamStreamTestMessages">[docs]</a><span class="k">class</span> <span class="nc">StreamStreamTestMessages</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
  270. <span class="sd">&quot;&quot;&quot;A type for stream-request-stream-response message pairings.&quot;&quot;&quot;</span>
  271. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span>
  272. <span class="nd">@abc.abstractmethod</span>
  273. <div class="viewcode-block" id="StreamStreamTestMessages.requests"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.StreamStreamTestMessages.requests">[docs]</a> <span class="k">def</span> <span class="nf">requests</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  274. <span class="sd">&quot;&quot;&quot;Affords a sequence of request messages.</span>
  275. <span class="sd"> Implementations of this method should return a different sequences with each</span>
  276. <span class="sd"> call so that multiple test executions of the test method may be made with</span>
  277. <span class="sd"> different inputs.</span>
  278. <span class="sd"> Returns:</span>
  279. <span class="sd"> A sequence of request messages.</span>
  280. <span class="sd"> &quot;&quot;&quot;</span>
  281. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  282. </div>
  283. <span class="nd">@abc.abstractmethod</span>
  284. <div class="viewcode-block" id="StreamStreamTestMessages.verify"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.StreamStreamTestMessages.verify">[docs]</a> <span class="k">def</span> <span class="nf">verify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">requests</span><span class="p">,</span> <span class="n">responses</span><span class="p">,</span> <span class="n">test_case</span><span class="p">):</span>
  285. <span class="sd">&quot;&quot;&quot;Verifies that the computed response matches the given requests.</span>
  286. <span class="sd"> Args:</span>
  287. <span class="sd"> requests: A sequence of request messages.</span>
  288. <span class="sd"> responses: A sequence of response messages.</span>
  289. <span class="sd"> test_case: A unittest.TestCase object affording useful assertion methods.</span>
  290. <span class="sd"> Raises:</span>
  291. <span class="sd"> AssertionError: If the requests and responses do not match, indicating</span>
  292. <span class="sd"> that there was some problem executing the RPC under test.</span>
  293. <span class="sd"> &quot;&quot;&quot;</span>
  294. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  295. </div></div>
  296. <div class="viewcode-block" id="TestService"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.TestService">[docs]</a><span class="k">class</span> <span class="nc">TestService</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
  297. <span class="sd">&quot;&quot;&quot;A specification of implemented RPC methods to use in tests.&quot;&quot;&quot;</span>
  298. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span>
  299. <span class="nd">@abc.abstractmethod</span>
  300. <div class="viewcode-block" id="TestService.name"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.TestService.name">[docs]</a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  301. <span class="sd">&quot;&quot;&quot;Identifies the RPC service name used during the test.</span>
  302. <span class="sd"> Returns:</span>
  303. <span class="sd"> The RPC service name to be used for the test.</span>
  304. <span class="sd"> &quot;&quot;&quot;</span>
  305. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  306. </div>
  307. <span class="nd">@abc.abstractmethod</span>
  308. <div class="viewcode-block" id="TestService.unary_unary_scenarios"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.TestService.unary_unary_scenarios">[docs]</a> <span class="k">def</span> <span class="nf">unary_unary_scenarios</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  309. <span class="sd">&quot;&quot;&quot;Affords unary-request-unary-response test methods and their messages.</span>
  310. <span class="sd"> Returns:</span>
  311. <span class="sd"> A dict from method name to pair. The first element of the pair</span>
  312. <span class="sd"> is a UnaryUnaryTestMethodImplementation object and the second element</span>
  313. <span class="sd"> is a sequence of UnaryUnaryTestMethodMessages objects.</span>
  314. <span class="sd"> &quot;&quot;&quot;</span>
  315. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  316. </div>
  317. <span class="nd">@abc.abstractmethod</span>
  318. <div class="viewcode-block" id="TestService.unary_stream_scenarios"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.TestService.unary_stream_scenarios">[docs]</a> <span class="k">def</span> <span class="nf">unary_stream_scenarios</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  319. <span class="sd">&quot;&quot;&quot;Affords unary-request-stream-response test methods and their messages.</span>
  320. <span class="sd"> Returns:</span>
  321. <span class="sd"> A dict from method name to pair. The first element of the pair is a</span>
  322. <span class="sd"> UnaryStreamTestMethodImplementation object and the second element is a</span>
  323. <span class="sd"> sequence of UnaryStreamTestMethodMessages objects.</span>
  324. <span class="sd"> &quot;&quot;&quot;</span>
  325. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  326. </div>
  327. <span class="nd">@abc.abstractmethod</span>
  328. <div class="viewcode-block" id="TestService.stream_unary_scenarios"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.TestService.stream_unary_scenarios">[docs]</a> <span class="k">def</span> <span class="nf">stream_unary_scenarios</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  329. <span class="sd">&quot;&quot;&quot;Affords stream-request-unary-response test methods and their messages.</span>
  330. <span class="sd"> Returns:</span>
  331. <span class="sd"> A dict from method name to pair. The first element of the pair is a</span>
  332. <span class="sd"> StreamUnaryTestMethodImplementation object and the second element is a</span>
  333. <span class="sd"> sequence of StreamUnaryTestMethodMessages objects.</span>
  334. <span class="sd"> &quot;&quot;&quot;</span>
  335. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
  336. </div>
  337. <span class="nd">@abc.abstractmethod</span>
  338. <div class="viewcode-block" id="TestService.stream_stream_scenarios"><a class="viewcode-back" href="../../../../../grpc.framework.face.testing.html#grpc.framework.face.testing.service.TestService.stream_stream_scenarios">[docs]</a> <span class="k">def</span> <span class="nf">stream_stream_scenarios</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  339. <span class="sd">&quot;&quot;&quot;Affords stream-request-stream-response test methods and their messages.</span>
  340. <span class="sd"> Returns:</span>
  341. <span class="sd"> A dict from method name to pair. The first element of the pair is a</span>
  342. <span class="sd"> StreamStreamTestMethodImplementation object and the second element is a</span>
  343. <span class="sd"> sequence of StreamStreamTestMethodMessages objects.</span>
  344. <span class="sd"> &quot;&quot;&quot;</span>
  345. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div></div>
  346. </pre></div>
  347. </div>
  348. <footer>
  349. <hr/>
  350. <div role="contentinfo">
  351. <p>
  352. &copy; Copyright 2015, Author.
  353. </p>
  354. </div>
  355. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  356. </footer>
  357. </div>
  358. </div>
  359. </section>
  360. </div>
  361. <script type="text/javascript">
  362. var DOCUMENTATION_OPTIONS = {
  363. URL_ROOT:'../../../../../',
  364. VERSION:'0.10.0a0',
  365. COLLAPSE_INDEX:false,
  366. FILE_SUFFIX:'.html',
  367. HAS_SOURCE: true
  368. };
  369. </script>
  370. <script type="text/javascript" src="../../../../../_static/jquery.js"></script>
  371. <script type="text/javascript" src="../../../../../_static/underscore.js"></script>
  372. <script type="text/javascript" src="../../../../../_static/doctools.js"></script>
  373. <script type="text/javascript" src="../../../../../_static/js/theme.js"></script>
  374. <script type="text/javascript">
  375. jQuery(function () {
  376. SphinxRtdTheme.StickyNav.enable();
  377. });
  378. </script>
  379. </body>
  380. </html>