<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Writing tests — Postorius 1.0a2 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '1.0a2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="top" title="Postorius 1.0a2 documentation" href="index.html" /> <link rel="next" title="Using the Django App - Developers Resource (outdated)" href="using.html" /> <link rel="prev" title="Installation" href="setup.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="using.html" title="Using the Django App - Developers Resource (outdated)" accesskey="N">next</a> |</li> <li class="right" > <a href="setup.html" title="Installation" accesskey="P">previous</a> |</li> <li><a href="index.html">Postorius 1.0a2 documentation</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-postorius.tests.test_utils"> <span id="writing-tests"></span><h1>Writing tests<a class="headerlink" href="#module-postorius.tests.test_utils" title="Permalink to this headline">¶</a></h1> <div class="section" id="mocking-mailman-client-objects"> <h2>Mocking mailman.client objects<a class="headerlink" href="#mocking-mailman-client-objects" title="Permalink to this headline">¶</a></h2> <div class="section" id="mailing-lists"> <h3>Mailing Lists<a class="headerlink" href="#mailing-lists" title="Permalink to this headline">¶</a></h3> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">postorius.tests.utils</span> <span class="kn">import</span> <span class="o">*</span> </pre></div> </div> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">properties</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">fqdn_listname</span><span class="o">=</span><span class="s">'testlist@example.org'</span><span class="p">,</span> <span class="gp">... </span> <span class="n">mail_host</span><span class="o">=</span><span class="s">'example.org'</span><span class="p">,</span> <span class="gp">... </span> <span class="n">list_name</span><span class="o">=</span><span class="s">'testlist'</span><span class="p">,</span> <span class="gp">... </span> <span class="n">display_name</span><span class="o">=</span><span class="s">'Test List'</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">mock_list</span> <span class="o">=</span> <span class="n">create_mock_list</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="gp">>>> </span><span class="k">print</span> <span class="n">mock_list</span><span class="o">.</span><span class="n">fqdn_listname</span> <span class="go">testlist@example.org</span> <span class="gp">>>> </span><span class="k">print</span> <span class="n">mock_list</span><span class="o">.</span><span class="n">mail_host</span> <span class="go">example.org</span> <span class="gp">>>> </span><span class="k">print</span> <span class="n">mock_list</span><span class="o">.</span><span class="n">list_name</span> <span class="go">testlist</span> <span class="gp">>>> </span><span class="k">print</span> <span class="n">mock_list</span><span class="o">.</span><span class="n">display_name</span> <span class="go">Test List</span> <span class="gp">>>> </span><span class="k">print</span> <span class="n">mock_list</span> <span class="go"><MagicMock name='List' id='...'></span> </pre></div> </div> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Writing tests</a><ul> <li><a class="reference internal" href="#mocking-mailman-client-objects">Mocking mailman.client objects</a><ul> <li><a class="reference internal" href="#mailing-lists">Mailing Lists</a></li> </ul> </li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="setup.html" title="previous chapter">Installation</a></p> <h4>Next topic</h4> <p class="topless"><a href="using.html" title="next chapter">Using the Django App - Developers Resource (outdated)</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/testing.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="using.html" title="Using the Django App - Developers Resource (outdated)" >next</a> |</li> <li class="right" > <a href="setup.html" title="Installation" >previous</a> |</li> <li><a href="index.html">Postorius 1.0a2 documentation</a> »</li> </ul> </div> <div class="footer"> © Copyright 2012, The Free Software Foundation. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2. </div> </body> </html>