fix: fixed broken tests for slack notification, added ability to run selected tests on local

This commit is contained in:
Andrii V 2025-04-03 18:22:53 +02:00
parent f602b2d5b1
commit a4ff9d4fab
2 changed files with 18 additions and 5 deletions

View file

@ -84,10 +84,19 @@ test-only:
rhodecode/tests/database rhodecode/tests/database
.PHONY: test-simple .PHONY: test-simple
# test-simple: Run tests only for main test suite witout coverage # test-simple: Run tests only for main test suite without coverage
test-simple: test-simple:
PYTHONHASHSEED=random \ PYTHONHASHSEED=random \
py.test -x -vv -r xw -p no:sugar \ py.test -r xw -p no:sugar \
--ignore=rhodecode/tests/vcs_operations \
--ignore=rhodecode/tests/database
.PHONY: test-custom
# test-custom: Run tests without coverage, only run tests matching PATTERN
test-custom:
PYTHONHASHSEED=random \
py.test $(if $(PATTERN),-k "$(PATTERN)",) -vv -r xw -p no:sugar \
--ignore=rhodecode/tests/vcs_operations \ --ignore=rhodecode/tests/vcs_operations \
--ignore=rhodecode/tests/database --ignore=rhodecode/tests/database

View file

@ -21,7 +21,7 @@ import mock
from mock import patch from mock import patch
from rhodecode import events from rhodecode import events
from rhodecode.integrations.types.handlers.slack import SlackDataHandler from rhodecode.integrations.types.handlers.slack import SlackDataHandler, SlackData
from rhodecode.model.db import Session, Integration from rhodecode.model.db import Session, Integration
from rhodecode.integrations.types.slack import SlackIntegrationType from rhodecode.integrations.types.slack import SlackIntegrationType
from rhodecode.tests import GIT_REPO from rhodecode.tests import GIT_REPO
@ -100,10 +100,14 @@ def slack_integration_empty(request, app, slack_settings):
def test_slack_push(slack_integration, repo_push_event): def test_slack_push(slack_integration, repo_push_event):
with patch("rhodecode.integrations.types.slack.post_text_to_slack") as call: with patch("rhodecode.integrations.types.slack.post_text_to_slack") as call:
events.trigger(repo_push_event) events.trigger(repo_push_event)
# make sure we can handle both dicts and dataclass objects
slack_data = call.call_args[0][1]
if isinstance(slack_data, dict):
slack_data = SlackData(**slack_data)
assert "pushed to" in call.call_args[0][1].title assert "pushed to" in slack_data.title
# specific commit was parsed and serialized # specific commit was parsed and serialized
assert "change that fixes #41" in call.call_args[0][1].text assert "change that fixes #41" in slack_data.text
def test_slack_push_no_events(slack_integration_empty, repo_push_event): def test_slack_push_no_events(slack_integration_empty, repo_push_event):