<p dir="ltr">Hi Sylvain, perhaps the responses library might be of use to you for mocking the requests library</p>
<p dir="ltr"><a href="https://pypi.python.org/pypi/responses">https://pypi.python.org/pypi/responses</a></p>
<p dir="ltr">Regards<br>
Dan</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Nov 2, 2016 12:50 PM, &quot;Sylvain Viart&quot; &lt;<a href="mailto:sylvain@opensource-expert.com">sylvain@opensource-expert.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Hi,<br>
    <br>
    I didn&#39;t find the answer yet, but I tested another approach with
    httmock package.<br>
    <br>
    <br>
    <a href="https://github.com/opensource-expert/powerdns-shell-wrapper/blob/dev-override-cmd-line/test/test_pdns_zone.py#L73" target="_blank">https://github.com/opensource-<wbr>expert/powerdns-shell-wrapper/<wbr>blob/dev-override-cmd-line/<wbr>test/test_pdns_zone.py#L73</a><br>
    <br>
    I also gonna explore setting up an instance of powerdns to have a
    fully testable environment.<br>
    <br>
    I you still have mocking / testing suggestion I&#39;m interested.<br>
    <br>
    Regards,<br>
    Sylvain.<br>
    <br>
    Nothing under this citation, new version has been commited, links
    may be wrong.<br>
    <blockquote type="cite">
      <p> I&#39;m having trouble to understand how to use correctly mock
        object to test correctness of requests&#39; call and also returned
        object. </p>
      <p> I&#39;m using <tt>py.test</tt> + <tt>pytest-mock</tt> </p>
      <p> I would like to test here that <tt>r.text</tt> is returned if
        I call:<br>
      </p>
      <div style="padding-left:30pt"> <tt>r = p.exec_pdns_api(&#39;GET&#39;,
          rest_url, text=True)</tt> </div>
      <a href="https://github.com/opensource-expert/powerdns-shell-wrapper/blob/dev-override-cmd-line/pdns_zone.py#L79" title="https://github.com/opensource-expert/powerdns-shell-wrapper/blob/dev-override-cmd-line/pdns_zone.py#L79" class="m_7171845359714765124https" target="_blank">https://github.com/opensource-<wbr>expert/powerdns-shell-wrapper/<wbr>blob/dev-override-cmd-line/<wbr>pdns_zone.py#L79</a>
      <p> how to I make an assertion that the <tt>r.text</tt> has been
        called/returned? </p>
      <p> r is <tt>&lt;MagicMock name=&#39;get().text&#39;
          id=&#39;139703066450704&#39;&gt;</tt> </p>
      <p> <tt>r.text.assert_called() </tt>is not the good assertion<br>
        test code here: <a href="https://github.com/opensource-expert/powerdns-shell-wrapper/blob/dev-override-cmd-line/test/test_pdns_zone.py#L40" target="_blank">https://github.com/opensource-<wbr>expert/powerdns-shell-wrapper/<wbr>blob/dev-override-cmd-line/<wbr>test/test_pdns_zone.py#L40</a><br>
      </p>
    </blockquote>
    <br>
    <pre class="m_7171845359714765124moz-signature" cols="72">-- 
Sylvain Viart - DevOps système linux - freelance developer</pre>
  </div>

<br>______________________________<wbr>_________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.<wbr>org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" rel="noreferrer" target="_blank">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a><br>
<br></blockquote></div></div>