Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On my GAE project, I use:</p> <ul> <li><a href="http://code.google.com/p/nose-gae/" rel="noreferrer">NoseGAE</a>&mdash;This is the critical piece that ties all the rest together</li> <li>Mock, as in John's excellent answer. I use this largely for AWS and other web services</li> <li>Fixtures (the package, not the idea)</li> </ul> <p>I also prefer many of Rails's idioms. I broke my tests into unit, and functional using Python packages. You can run a subset of tests using <code>--tests=unit</code> or <code>--tests=functional</code>. It is all a bit more manual than Rails but at least I can unit test the hard stuff and make sure I never have regressions.</p> <p>I also made a simple <code>FunctionalTest</code> class to do much of the very common actions in Rails, such as <code>assert_response</code> and <code>assert_xpath</code> (similar to assert_select).</p> <pre><code>class FunctionalTest(Test): def get(self, *args, **kw): self.response = app.get(*args, **kw) def post(self, *args, **kw): self.response = app.post(*args, **kw) def assert_response(self, expected): pattern = str(expected) if re.search(r'^\d+$', expected) \ else (r'^\d+ %s' % expected) assert re.search(pattern, self.response.status, re.IGNORECASE), \ 'Response status was not "%s": %s' % (expected, self.response.status) def assert_xpath(self, path, expected): element = ElementTree.fromstring(self.response.body) found_nodes = element.findall('.' + path) if type(expected) is int: assert_equal(expected, len(found_nodes)) elif type(expected) is str or type(expected) is unicode: assert (True in [(node.text == expected) for node in found_nodes]) else: raise Exception, "Unknown expected value: %r" % type(expected) </code></pre> <p>If you are doing lots of ListElement equality searches, definitely learn the <code>--tests=foo</code> syntax because testing for matching elements within a list is very slow.</p> <p>Sometimes I like to load the Rails console against my fixture data to see what's going on in the test environment (i.e. <code>script/console test</code>). To do something similar with GAE, run dev_appserver.py with the parameter <code>--datastore_path="$TMPDIR/nosegae.datastore"</code> (or possibly substitute <code>/tmp</code> for <code>$TMPDIR</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload