Add unit tests for ecosystem/github.py to increase code coverage from 28% to 94%#1163
Add unit tests for ecosystem/github.py to increase code coverage from 28% to 94%#1163abzsd wants to merge 10 commits into
Conversation
| @@ -0,0 +1,226 @@ | |||
| """Tests for ecosystem/github.py""" | |||
|
|
|||
| # pylint: disable=protected-access | |||
| """Tests for GitHubData.__getattr__""" | ||
|
|
||
| def setUp(self): | ||
| self.gh = GitHubData(owner="Qiskit", repo="qiskit-ecosystem") |
There was a problem hiding this comment.
consider network mocking to populate _json_repo instead of hardcode it. Internal might change at any point.
| gh._json_package_ids = {} | ||
| gh.update_json() | ||
| self.assertIsNotNone(gh._json_repo) |
| gh._json_dependants = { | ||
| "pkg1": {"repositories": 10}, | ||
| "pkg2": {"repositories": 5}, | ||
| } |
There was a problem hiding this comment.
Network mock for populating _json_dependants
| gh._json_dependants = { | |
| "pkg1": {"repositories": 10}, | |
| "pkg2": {"repositories": 5}, | |
| } |
Co-authored-by: Luciano Bello <766693+1ucian0@users.noreply.github.com>
|
Hi there @1ucian0, just saw the coverage and tests check/Github actions giving an error, just let me know if I need to make some more changes. Does my code need to pass those checks as well to get merged? |
|
Got it, I had used |
|
Hi there @1ucian0, Hope you're doing well, |
Summary
Added unit tests for
ecosystem/github.pyto increase code coverageFixes the following Issue : #1107
Details and comments
Added
tests/github/test_github.pywith 25 tests covering:GitHubData.__init__: Default values and kwargs storageGitHubData.from_url: Valid URLs, non-GitHub URLS, tree paths, and invalid URLsGitHubData.to_dict: serialization and None value exclusionGitHubData.__getattr__: type transform and AttributeError casesGitHubData.update_owner_repo: rename detectionGitHubData.update_json: verifies JSON fields are populated and dependents are fetched per packageGitHubData.dependants: refresh behaviourGitHubData.total_dependent_repositories/total_dependent_packages: property computationsI have added the tests to cover my changes.
I have updated the documentation accordingly.
I have read the CONTRIBUTING document.