I've generally speaking been a fairly good boy when it comes to writing unit tests for chrss, but I know I haven't covered everything. Most of the focus has been on the underlying chess module, so I thought I'd best have a look and see what my actual unit test code coverage was like (i.e. how much of the code is actually getting run during tests).
Nosetests has a handy --with-coverage option, that requires installing coverage.py, for just this problem.
Running:
nosetests --with-coverage --cover-package=chrss --cover-erase
Then gives me the following output:
Name Stmts Exec Cover Missing ------------------------------------------------------ chrss 0 0 100% chrss.chess2 578 549 94% 69, 260, 274, 281-286, 302, 340, 343-344, 347, 349, 351, 365, 367, 371, 382-384, 387, 389, 391, 680, 886, 918, 921, 939 chrss.config 0 0 100% chrss.controllers 504 232 46% 35-36, 39, 50, 52, 54, 56, 58, 60, 62, 186, 195, 197, 210-237, 248-257, 261-266, 271-277, 282-290, 296-301, 307-311, 316-323, 330, 341-346, 352-380, 428, 435, 462, 478-479, 482-494, 498, 508, 512, 516, 520, 524, 529-531, 537-553, 558-566, 593, 601, 606-618, 627, 630, 636-637, 644-648, 652-678, 683-685, 690, 694-710, 714-739, 744-755, 758-760, 763-776, 779-798 chrss.model 325 228 70% 66, 68, 75, 82, 84, 91, 94, 101, 106, 115, 131-133, 136-142, 160, 164, 170-179, 187, 191-198, 207, 209, 222-224, 228, 231, 237, 245-265, 308-310, 326-335, 338-339, 354-355, 427-436, 439-442, 445-446, 455, 458-461 chrss.rest 31 0 0% 1-43 chrss.rss 86 50 58% 14, 18, 48-58, 67, 81-91, 95-105 chrss.templates 0 0 100% chrss.templates.master 305 236 77% 28-29, 43, 61-65, 79, 107, 135, 148, 217, 226-249, 268, 295, 321, 346, 357, 409-430, 444-447, 453, 509-510 chrss.urls 34 0 0% 1-57 chrss.widgets 131 115 87% 7-11, 61, 68, 109-114, 147-148, 158 ------------------------------------------------------ TOTAL 1994 1410 70% ----------------------------------------------------------------------
So overall I am (apparently) managing 70% coverage and the core chrss.chess2 module has 94% coverages. Not too bad I suppose. However I could do better and there are some notable gaps. In particular chrss.controllers only has 46% coverage and that represents some fairly important code for the whole site.
I've held of writing tests for some of the controller functions, as they involve sending email (signups, resetting passwords etc). I'll have to write some sort of email mock class for that purpose, but it will be worth it as I can then be more certain things are working as they are intended.