[Sugar-devel] Tests for online service support

Daniel Narvaez dwnarvaez at gmail.com
Mon May 20 06:39:14 EDT 2013


Hello,

I'm posting my initial thoughts about writing tests for the first online
service pull request here, it might be interesting for people working on
other patch sets too.

https://github.com/sugarlabs/sugar/pull/59

A good preliminary reading

http://docs.python.org/2/library/unittest.html

On the practical side, you can add a test by just creating a file in
sugar/tests. As long as you have classes inheriting from unittest.TestCase,
they will be picked up by "make test".

It seems like we should be able to test all the public methods in this
patch.  We will need to provide a mock implementation of the service and
make sure it gets picked up by get_all_accounts, probably by tweaking
config.ext_path from the test. We could have a sugar/tests/extensions for
this and other mock extensions implementations.

Random list of things you could test with that in place:

* get_all_accounts returns the mock service
* get_configured_accounts return the  mock service only if Account returns
that it's configured
* Same for get_active_accounts
* Loading an icon from the mock service works.
* All the Account methods returns what expected.
* All the MenuItem signals are emitted as expected.
* Calling set_metadata results in the expected change to the journal object.

The main problem I anticipate is that I'm not sure datastore will be
functional in the test. Let's give it a try, if it's not we can decide if
we want to make datastore work there or if we prefer to mock the journal
entry.

I hope this is useful. I'm happy to help as much as I can with this... so
feel free to post about any problem/doubts/thoughts you run into. We should
probably do this step by step because we are probably going to run in
multiple problems, and some we will find by just trying it out. Making
get_all_accounts work would probably be a good first step.

-- 
Daniel Narvaez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20130520/ead502e8/attachment.html>


More information about the Sugar-devel mailing list