mozilla/minion-backend — pull request #300 by yeukhon (2014-02-07 10:14:03+00:00)
Title: Fixed #184. Refactor and re-implement all views functional tests.

This is a major patch.

First, there is a base class called Resource which is used to
create "shortcut" class to each of the backend's resource endpoint.
While it may be silly to create such class, as a test writer I find
this approach cleaner, more readable and easier to maintain than
the previous function-style.

Compare:

user = User("bob@example.org")
res = user.create()

to

res = self.create_user("bob@eample.org")

The class actually keeps certain "states" (at the attribute level).
Most of the classes have the same number of methods to access:

create, get, update, delete

Secondly, when we actually test scan, we no longer run basics plugin,
which would require a mini Flask server to be running. Instead,
I am making use of DelayPlugin from tests plugin. However, this test
is turned off due to bug #296 (and #300). Until we fix those two,
that test will be commented out.

Third, test_key method is gone. When we want to check whether
the response contains keys we are expecting to have, we fall back
to the native self.assertEqual. We basically do this:

self.assertEqual(set(key1), set(key2))

where key1 and key2 are the set of keys we want to compare. While
doing this, I discovered that the original self._test_key method
contains a bug. We have added new keys to many responses but _test_key
did not catch the changes. With this new, more native approach,
I am able to detect the missing keys and this improve the realibitly of
our tests.

There are other changes, but in general this patch makes the tests
more robuts and easier to maintain.