SIENTIAPDE-1974: refactor(slots): fix the SonarQube quality gate findings
SonarQube on PR #45 reported 3 new issues; all fixed without behavior change: - S3776 gather_read_tags (cognitive complexity 22): the merge of one resolved read tag into its (server, address) entry moves to _add_read_tag (now 14). - S3776 Orchestrator.run (16): the tag database load moves to Orchestrator._load_tag_database (run back to 14). workflow.patched() is still evaluated first on every execution, so its marker is always recorded. - S1192 '$match' duplicated in the workflow module: the connector_tags tag_id filter moves to orchestrator_functions.filter_by_tag_ids, which also returns a new aggregation list. 194 unit tests (new: filter_by_tag_ids); real workflow on a local Temporal test server still passes the 3 scenarios; the dev dry run is still equivalent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ from orchestrator.utils.orchestrator_functions import (
|
||||
build_tag_config,
|
||||
common_config,
|
||||
drift,
|
||||
filter_by_tag_ids,
|
||||
gather_read_tags,
|
||||
index_connector_tags,
|
||||
index_connectors,
|
||||
@@ -764,6 +765,20 @@ def test_referenced_tag_ids_without_tag_ids():
|
||||
assert referenced_tag_ids([pipeline, no_read_tags]) == []
|
||||
|
||||
|
||||
def test_filter_by_tag_ids():
|
||||
"""A tag_id $match goes in front, on a new aggregation list"""
|
||||
query = {'collection': 'connector_tags', 'aggregation': [{'$project': {'_id': 0}}]}
|
||||
|
||||
result = filter_by_tag_ids(query, [7, '7'])
|
||||
|
||||
assert result == {
|
||||
'collection': 'connector_tags',
|
||||
'aggregation': [{'$match': {'tag_id': {'$in': [7, '7']}}}, {'$project': {'_id': 0}}],
|
||||
}
|
||||
assert result['aggregation'] is not query['aggregation']
|
||||
assert query['aggregation'] == [{'$project': {'_id': 0}}]
|
||||
|
||||
|
||||
def test_index_skips_incomplete_documents():
|
||||
"""A malformed tag database document is left out instead of failing the run"""
|
||||
tags = [
|
||||
|
||||
Reference in New Issue
Block a user