Skip to content

Unit testing improvements#323

Merged
MoralCode merged 16 commits into
mainfrom
unit_testing_improvements
May 20, 2026
Merged

Unit testing improvements#323
MoralCode merged 16 commits into
mainfrom
unit_testing_improvements

Conversation

@MoralCode
Copy link
Copy Markdown
Contributor

@MoralCode MoralCode commented May 18, 2026

Description
This PR makes general improvements to testing, including:

  • adding unit tests for new endpoint url behavior introduced in Bypass collecting pull request data when PRs are disabled #306
  • moves some imports to remove one of the several roadblocks to improving application unit test coverage.
  • actually run all the tests configured in the .toml file
  • reorganize and improve labeling of some of the tests

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

  • Yes, I signed my commits.

Inengs and others added 10 commits May 18, 2026 14:42
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>
Copy link
Copy Markdown

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'gda' from outer scope (line 19) (redefined-outer-name)

uid = GithubUUID()
uid["user"] = 10

result = uid.__dict__()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused UnresolvableUUID imported from collectoss.tasks.util.ContributorUUID (unused-import)

@@ -2,11 +2,11 @@
import pytest
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused import pytest (unused-import)

@@ -2,11 +2,11 @@
import pytest
import sqlalchemy as s
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused sqlalchemy imported as s (unused-import)

MoralCode added 6 commits May 19, 2026 09:06
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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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__()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused UnresolvableUUID imported from collectoss.tasks.util.ContributorUUID (unused-import)

@MoralCode MoralCode merged commit 3bf9696 into main May 20, 2026
19 of 20 checks passed
@MoralCode MoralCode deleted the unit_testing_improvements branch May 20, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants