Unit testing improvements#323
Conversation
Signed-off-by: Inengs <inengiyeemmanuel@gmail.com>
Signed-off-by: Inengs <inengiyeemmanuel@gmail.com>
Signed-off-by: Inengs <inengiyeemmanuel@gmail.com>
Signed-off-by: Inengiye Emmanuel <inengiyeemmanuel@gmail.com>
…intended These pass but require that the collectoss/tasks/github/__init__.py file be commented out first before they will run Co-Authored-By: Cursor Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
this prevents them from messing with unit testing stuff Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
There was a problem hiding this comment.
Bandit found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
|
|
||
|
|
||
| @pytest.fixture | ||
| def gda(mock_key_manager, mock_logger): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_key_manager' from outer scope (line 14) (redefined-outer-name)
|
|
||
|
|
||
| @pytest.fixture | ||
| def gda(mock_key_manager, mock_logger): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
|
|
||
| class TestEndpointUrl: | ||
|
|
||
| def test_basic_path(self, gda): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'gda' from outer scope (line 19) (redefined-outer-name)
| result = gda.endpoint_url("/users/MoralCode") | ||
| assert result == "https://api.github.com/users/MoralCode" | ||
|
|
||
| def test_path_without_leading_slash(self, gda): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'gda' from outer scope (line 19) (redefined-outer-name)
| result = gda.endpoint_url("repos/owner/repo") | ||
| assert result == "https://api.github.com/repos/owner/repo" | ||
|
|
||
| def test_with_single_param(self, gda): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'gda' from outer scope (line 19) (redefined-outer-name)
| result = gda.endpoint_url("/users/MoralCode", {}) | ||
| assert result == "https://api.github.com/users/MoralCode" | ||
|
|
||
| def test_path_with_existing_query_params(self, gda): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'gda' from outer scope (line 19) (redefined-outer-name)
| uid = GithubUUID() | ||
| uid["user"] = 10 | ||
|
|
||
| result = uid.__dict__() |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
E1102: uid.dict is not callable (not-callable)
| @@ -0,0 +1,160 @@ | |||
| import pytest | |||
| import uuid | |||
| from collectoss.tasks.util.ContributorUUID import ContributorUUID, GithubUUID, GitlabUUID, UnresolvableUUID | |||
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0611: Unused UnresolvableUUID imported from collectoss.tasks.util.ContributorUUID (unused-import)
| @@ -2,11 +2,11 @@ | |||
| import pytest | |||
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0611: Unused import pytest (unused-import)
| @@ -2,11 +2,11 @@ | |||
| import pytest | |||
| import sqlalchemy as s | |||
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0611: Unused sqlalchemy imported as s (unused-import)
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
| getattr(cfg, callable_name)(*args, **kwargs) | ||
| class TestJSONConfig: | ||
|
|
||
| def test_jsonconfig_readonly_flags(self, mock_logger): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
| assert cfg.empty is False | ||
|
|
||
|
|
||
| def test_jsonconfig_empty_true_false(self, mock_logger): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
| assert JsonConfig({"A": {}}, mock_logger).empty is False | ||
|
|
||
|
|
||
| def test_jsonconfig_write_protection(self, mock_logger): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
| config_test = cfg.retrieve_dict() | ||
| assert config_test != data # the data in the config should not change | ||
|
|
||
| def test_jsonconfig_retrieve_has_get(self, mock_logger): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
| ("add_value", ("X", "y", 2), {"ignore_existing": False}), | ||
| ], | ||
| ) | ||
| def test_jsonconfig_mutations_raise_not_writable(self, mock_logger, callable_name, args, kwargs): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
| getattr(cfg, callable_name)(*args, **kwargs) | ||
|
|
||
|
|
||
| def test_fetching_real_defaults(self, mock_logger, mock_session): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
| getattr(cfg, callable_name)(*args, **kwargs) | ||
|
|
||
|
|
||
| def test_fetching_real_defaults(self, mock_logger, mock_session): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_session' from outer scope (line 13) (redefined-outer-name)
| assert len_contributors_list == 0 | ||
|
|
||
| def test_github_paginator_get_item(key_auth): | ||
| def test_github_paginator_get_item_2(key_auth): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'key_auth' from outer scope (line 14) (redefined-outer-name)
| uid = GithubUUID() | ||
| uid["user"] = 10 | ||
|
|
||
| result = uid.__dict__() |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
E1102: uid.dict is not callable (not-callable)
| @@ -0,0 +1,161 @@ | |||
| import pytest | |||
| import uuid | |||
| from collectoss.tasks.util.ContributorUUID import ContributorUUID, GithubUUID, GitlabUUID, UnresolvableUUID | |||
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0611: Unused UnresolvableUUID imported from collectoss.tasks.util.ContributorUUID (unused-import)
Description
This PR makes general improvements to testing, including:
Notes for Reviewers
This PR contains some signed-off contributions from @Inengs that were originally filed as augurlabs/augur#3749 (adding unit tests for the ContributorUUID class, which was renamed as part of the fork)
Ill consider this tested if all CI tests pass
Signed commits