<div dir="ltr"><div><div>Hello,<br><br></div>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.<br><br>
<a href="https://github.com/sugarlabs/sugar/pull/59">https://github.com/sugarlabs/sugar/pull/59</a><br><br></div><div>A good preliminary reading<br><br><a href="http://docs.python.org/2/library/unittest.html">http://docs.python.org/2/library/unittest.html</a><br>
</div><div><br></div>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".<br clear="all">
<div><div><div><div><br></div><div>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.<br>
</div><div><br></div><div>Random list of things you could test with that in place:<br><br>* get_all_accounts returns the mock service<br>* get_configured_accounts return the mock service only if Account returns that it's configured<br>
</div><div>* Same for get_active_accounts<br></div><div>* Loading an icon from the mock service works.<br></div><div>* All the Account methods returns what expected.<br></div><div>* All the MenuItem signals are emitted as expected.<br>
</div><div>* Calling set_metadata results in the expected change to the journal object.<br><br></div><div>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.<br>
</div><div><br></div><div>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.<br>
</div><div><br>-- <br>Daniel Narvaez<br></div></div></div></div></div>