DESCRIPTION

Integrate view tests with new view_helper module

Change-Id: I9fef0b27b549a469b9fd78996304cabac05e0ff9


COMMENTS

author: Titus Ho
date: 2012-03-29 12:27:43.199000000

Uploaded patch set 2.

-------------------------------------
author: Ayla Reynolds
date: 2012-03-29 13:59:03.530000000

Patch Set 2: (13 inline comments)

More info when to use "is" or "==": http://me.veekun.com/blog/2012/03/24/python-faq-equality/
The conclustion is: "don’t use is unless you’re comparing with None or you really, really mean it. :)"

Line:34, lib/couchbase/view_helper.py -> This function is not needed, urllib.urlencode(params) can be used instead.

Line:45, lib/couchbase/view_helper.py -> Renaming expected_keys to num_expected_keys would make things clearer.

Line:71, lib/couchbase/view_helper.py -> Renaming expected_keys to num_expected_keys would make things clearer.

Line:80, lib/couchbase/view_helper.py -> Second parameter should be `design_doc_name` and not `view_name`.

Line:82, lib/couchbase/view_helper.py -> `None` should be compared with `is`, not with `==`

Line:98, lib/couchbase/view_helper.py -> This function is highly confusing. Please add a comment. It took me a while to understand, that the value of the rows contain the number of keys that were grouped by the reduce.

The for loop can be simplified to:

    for row in results['rows']:
        num_keys += row['value']

Line:104, lib/couchbase/view_helper.py -> You don't really assert things, but you throw an error (hence the function should also be renamed). I'm not even sure if it should be an assertion error, or rather just another exception.

In case you want to have an AssertionError, it would be better to use:
raise AssertionError("Query {0} failed {1} times. Test Failed".format(view_name, tries))

(this is from http://docs.python.org/reference/simple_stmts.html#the-assert-statement)

Line:109, lib/couchbase/view_helper.py -> Same as for _assert_query_max_tries().

Line:259, pytests/viewquerytests.py -> Shouldn't be `is` but `==`

Line:263, pytests/viewquerytests.py -> Use self.bucket instead of hard-coding "default".

Line:266, pytests/viewquerytests.py -> Use self.bucket instead of hard-coding "default".

Line:475, pytests/viewtests.py -> Should we still keep this part? I think it's better to explicit, rather then implicit. As we pass is the 'full_set' argument, I think it would be confusing if you set 'full_set' to "false" but it uses the full set, because the view starts with "dev_".

If we keep it, it should be:

    if view.startswith("dev_"):

Line:485, pytests/viewtests.py -> '== None' should be 'is None'.

`and limit != None` is not needed, if it would be `None` the upper if statement would match.

-------------------------------------
