← Back to team overview

software-store-developers team mailing list archive

Fake Review Functionality

 

Hi guys,

Something I've been working on for a while has just been merged to
trunk (with some help from mvo along the way - thanks).

I'm hoping it will be useful for you all at some point, so sharing it now.

It is a 'fake' review API suite which pretends to be the server for
all review functionality including the SSO login stuff. Basically, it
provides a fake version of rnrclient, loginbackendSSO and
ubuntuSSOapi.

To use it, you can simply export SOFTWARE_CENTER_FAKE_REVIEW_API='1'
to os.environ and the app should transparently use the fake API.

What's the point?
Basically, you can play with some settings to make the API act exactly
as you need it to without any unexpected results which you might get
if you are trying to use a real review server. It also avoids actually
hitting a real review server (or network at all for that matter). e.g.
if you are trying to test a change to submit review, you don't have to
submit multiple real reviews to a real server and work around the
real-life rules that are in place on the server.

Some examples of what you can do: add a fake network delay, force an
rnrclient method to raise an exception for testing error conditions or
have it return a certain number of reviews, votes etc.

To see each of the settings that are currently available, take a look
at the file test/fake_review_settings.py. I've tried to document each
setting in the comments as best I can.
In the FakeReviewSettings class, each key/val pair in the
_FAKE_SETTINGS dict is a setting you can change to alter the API's
behaviour.
To change the settings, import and instantiate FakeReviewSettings()
then use update_setting() or update_multiple(). This writes the
settings to a cache file and the app then retrieves them from the file
when it needs them.
If you don't want to be bound by the settings that were in the file
from last time you used it, pass True to the FakeReviewSettings()
__init__ and it will overwrite the cache file with the default values
as a starting point.

You can use this in test cases or in real UI interaction with the app.
For the latter, you can use the run_with_fake_review_api.sh script to
fire it up.

If you get a chance, please give it a go and see if you can break it
so we can make it better. Also, if you identify any new settings that
it needs or things we can do to make it more useful, let me know and
I'll add them in (or add them yourself if you like)

Hope this helps!

cheers
Aaron