remove asumption of order from test_simple_queries #84

Merged
merged 5 commits into from May 12, 2014
Commits on Mar 12, 2014
  1. @felliott
  2. @felliott

    fix simple queries tests to match Mongo semantics

    felliott committed Mar 12, 2014
     * The Pickle and Mongo backends disagreed on how .sort(), .limit(), and
       .offset() work together.  The tests were originally written to match
       the Pickle semantics, but it has been decided that going forwards,
       the Mongo semantics will hold sway.  Summary:
    
       * sort(), offset(), and limit() are now setters.  Successive calls to
         a function will overwrite the previous value.  No evaluation will
         be performed by these functions.  The underlying data will only be
         updated when __iter__, __getitem__, or __len__ is called.  E.g.
         Foo.find().limit(10).limit(15) will return 15 items.
    
       * The constraints are always processed in the same order regardless
         of the order in which they are declared.  sort()s are run first,
         then offset(), then limit(). E.g.
         Foo.find().limit(10).offset(5).sort("_id") will sort first, then
         apply the offset, then limit the returned results to 10.
  3. @felliott
  4. @felliott

    test_simple_queries: remove FIFO assumption, reorg

    felliott committed Mar 12, 2014
     * the tests in test_simple_queries were assuming that objects were
       being returned in the order they were inserted, i.e. there was a
       default sort order.  Many of the limit/offset tests were testing
       against an exact set of data, instead of just testing the size of the
       returned set.  The limit/offset tests without sort only test size of
       returned values now.
    
     * Since limit/offset/sort are evaluated lazily and always in sort,
       offset, then limit order, I've reorganized the tests.  There is one
       test for each of the three filters, one test for all three together,
       and one test for each unique tuple in the set of {l,o,s}x{l,o,s}. For
       example, the .limit().offset() test is grouped with the
       .offset().limit() test, since the expected result should be the same.
  5. @felliott

    oops, we don't actually need _listIsSorted

    felliott committed Mar 12, 2014
     * since a sort filter applies before offset and limit, we can predict
       what the exact return value will be