Skip to content

Building a Better Democracy for the Internet Age

License

Notifications You must be signed in to change notification settings

LaraTifui/OpenCiviWiki

 
 

Repository files navigation

Report for Assignment 1 resit

Project chosen

Name: CiviWiki

URL: https://github.com/LaraTifui/OpenCiviWiki

Number of lines of code and the tool used to count it: 4958 line (using lizard)

Programming language: Python

Coverage measurement with existing tool

Tool used: Coverage.py

Execution:

        coverage run --branch -m pytest // for the test
        
        coverage report // to see the report
        
        coverage html // to see the report as well as the code covered, in html form

Initial run of the tool (in terminal):

init cov report part1 init cov report part2

Coverage improvement

Individual tests

Function 1

In project/accounts/tests/test_models.py I have added a test that checks if the profile has a set profile image. The function profile_image_url, had 50% branch test coverage, since a unit test already existed in the case a profile had no image associated with it, so the default image is used. After adding 1 unit tests , in order to check if the profile is correctly set when an image is associated with the profile, the function has now 100% branch coverage and the total coverage of the models.py file has raised from 57% to 86%

Code: image

The commit link for the new test for function 1: https://github.com/LaraTifui/OpenCiviWiki/commit/1fa0f9baf80d0e7188b4991ccb1915d41e389588#diff-6ca9982ebb8b28073aa65d5339359b92b701121f06ac0ba9b3606b81c83bdc69

Old coverage result: func1 init uncovered 1

New coverage result: func1 final covered

Old coverage: func1 init stat

New coverage:

func1 final stat

Function 2

In project/accounts/tests/test_utils.py there is a function called get_account to which I created a test for. The function get_account, which has 3 optional parameters, had 0% test coverage. After adding 5 unit tests , in order to check each of the possible calling situations covered by the function coding, the function has now 100% branch coverage and the total coverage of the utils.py file has raised from  32% to 65%.

The commit link for the new test for function 1: https://github.com/LaraTifui/OpenCiviWiki/commit/3c1d9fb5b823a0cbf4a2b359affa05db09de8bf7

Old coverage result:

func2 init uncovered get_account

New coverage result:

func2 final covered

Old coverage:

func2 init stat

New coverage:

func2 final stat

Overall

Initial run of the tool (in html form):

init index cov part1 init index cov part2

Final run of the tool (in html form):

fin index cov part1 fin index cov part2

About

Building a Better Democracy for the Internet Age

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 39.6%
  • HTML 26.7%
  • JavaScript 17.3%
  • Less 15.0%
  • CSS 1.4%