{"action":"created","issue":{"url":"https://api.github.com/repos/flavour/eden/issues/1034","labels_url":"https://api.github.com/repos/flavour/eden/issues/1034/labels{/name}","comments_url":"https://api.github.com/repos/flavour/eden/issues/1034/comments","events_url":"https://api.github.com/repos/flavour/eden/issues/1034/events","html_url":"https://github.com/flavour/eden/pull/1034","id":54211199,"number":1034,"title":"[S3Method]: Download assessment form(.xls and .rtf) working","user":{"login":"raj454raj","id":6368364,"avatar_url":"https://avatars.githubusercontent.com/u/6368364?v=3","gravatar_id":"","url":"https://api.github.com/users/raj454raj","html_url":"https://github.com/raj454raj","followers_url":"https://api.github.com/users/raj454raj/followers","following_url":"https://api.github.com/users/raj454raj/following{/other_user}","gists_url":"https://api.github.com/users/raj454raj/gists{/gist_id}","starred_url":"https://api.github.com/users/raj454raj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raj454raj/subscriptions","organizations_url":"https://api.github.com/users/raj454raj/orgs","repos_url":"https://api.github.com/users/raj454raj/repos","events_url":"https://api.github.com/users/raj454raj/events{/privacy}","received_events_url":"https://api.github.com/users/raj454raj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-01-13T16:04:28Z","updated_at":"2015-01-20T19:23:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/flavour/eden/pulls/1034","html_url":"https://github.com/flavour/eden/pull/1034","diff_url":"https://github.com/flavour/eden/pull/1034.diff","patch_url":"https://github.com/flavour/eden/pull/1034.patch"},"body":"I have removed the code for \"from PyRTF import something\" and replaced by \"from gluon.contrib.pyrtf import *\" because now web2py has pyrtf module inbuilt. No need to check whether user have it installed or not!!! YAY !!!"},"comment":{"url":"https://api.github.com/repos/flavour/eden/issues/comments/70715123","html_url":"https://github.com/flavour/eden/pull/1034#issuecomment-70715123","issue_url":"https://api.github.com/repos/flavour/eden/issues/1034","id":70715123,"user":{"login":"nursix","id":1257183,"avatar_url":"https://avatars.githubusercontent.com/u/1257183?v=3","gravatar_id":"","url":"https://api.github.com/users/nursix","html_url":"https://github.com/nursix","followers_url":"https://api.github.com/users/nursix/followers","following_url":"https://api.github.com/users/nursix/following{/other_user}","gists_url":"https://api.github.com/users/nursix/gists{/gist_id}","starred_url":"https://api.github.com/users/nursix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nursix/subscriptions","organizations_url":"https://api.github.com/users/nursix/orgs","repos_url":"https://api.github.com/users/nursix/repos","events_url":"https://api.github.com/users/nursix/events{/privacy}","received_events_url":"https://api.github.com/users/nursix/received_events","type":"User","site_admin":false},"created_at":"2015-01-20T19:23:16Z","updated_at":"2015-01-20T19:23:16Z","body":"So, stage 1 and 2 are done - next would be 3.\r\n\r\nBut before working on 3, you should indeed have some unit tests. Unit tests test functions in isolation, i.e. you call a function with mockup-parameters and verify the results. Ideally, you check both success and failure response.\r\n\r\nA schematic example. Say you have a function like this:\r\n\r\n    def myfunc(a, b):\r\n        return a / b\r\n\r\nThen a unit test could be like this:\r\n\r\n    def test_myfunc():\r\n        result = myfunc(4, 2)\r\n        if result != 2:\r\n            raise AssertionError(\"Wrong result: should have been 2, but was %s.\" % result)\r\n\r\nSo you're writing another function to call the function that is to be tested, with parameters for which you know the result, in order to prove that the function really returns the expected result.\r\n\r\nTypically, you should have at least one test call for each distinct type of case - e.g. for myfunc() this would additionally be the cases where either parameter is 0.\r\n\r\nTo make writing unit tests easier, Python provides a library \"unittest\" that supports more complex testing strategies and assertion checking. See modules/unit_tests - there are various examples of how unit tests could look like.\r\n\r\nImportant is that you don't ever use the tested function itself to determine which results you should expect ;) because then the unit test doesn't prove anything except for the fact that two identical calls deliver the same results.\r\n\r\nNow, in order to write unit tests for this module, you need to look at each function and understand what results it should deliver for which input - and try to find a way to inspect and verify the result. Then identify the assertions (=expected results) for each type of case, and encode it as a test case.\r\n\r\nE.g., get_style_list() should always return a dict() with certain members - that is an easy assertion, and quick to code. writeToRTF() is more complicated, but can still be introspected.\r\n\r\nYou do not need to test the overall functionality - all we need to know is whether the parts still do after the refactoring what they did before, the results are still correct, and no new bugs have been introduced (=regression testing)."}}