Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ This project adheres to [Semantic Versioning](https://semver.org/). Version numb
- **MINOR**: New features that are backward-compatible.
- **PATCH**: Bug fixes or minor changes that do not affect backward compatibility.

## [1.12.2]

_released 10-16-2025

### Added
- Allow adding references via parse_junit command using --test-run-ref
- Allow parse_junit to update existing test cases reference field from JUnit testrail_case_field properties

## [1.12.1]

_released 09-30-2025
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trcli
```
You should get something like this:
```
TestRail CLI v1.12.1
TestRail CLI v1.12.2
Copyright 2025 Gurock Software GmbH - www.gurock.com
Supported and loaded modules:
- parse_junit: JUnit XML Files (& Similar)
Expand Down Expand Up @@ -87,6 +87,7 @@ Commands:
parse_junit Parse JUnit report and upload results to TestRail
parse_openapi Parse OpenAPI spec and create cases in TestRail
parse_robot Parse Robot Framework report and upload results to TestRail
references Manage references in TestRail
```

Uploading automated test results
Expand Down Expand Up @@ -136,8 +137,16 @@ Options:
--allow-ms Allows using milliseconds for elapsed times.
--special-parser Optional special parser option for specialized JUnit
reports.
-a, --assign Comma-separated list of user emails to assign failed test
results to.
-a, --assign Comma-separated list of user emails to assign failed
test results to.
--test-run-ref Comma-separated list of reference IDs to append to the
test run (up to 250 characters total).
--json-output Output reference operation results in JSON format.
--update-existing-cases Update existing TestRail cases with values from
JUnit properties (default: no).
--update-strategy Strategy for combining incoming values with
existing case field values, whether to append or
replace (default: append).
--help Show this message and exit.
```

Expand Down
70 changes: 66 additions & 4 deletions tests/test_api_request_handler_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def test_add_case_references_character_limit_exceeded(self, references_handler):

with patch.object(references_handler.client, 'send_get', return_value=mock_get_case_response):

# Try to add more refs that would exceed 2000 chars
long_refs = ["REQ-" + "X" * 500 for _ in range(5)]
# Try to add more refs that would exceed 2000 chars (using unique refs to account for deduplication)
long_refs = [f"REQ-{i}-" + "X" * 500 for i in range(5)]

success, error = references_handler.add_case_references(
case_id=1,
Expand All @@ -185,6 +185,43 @@ def test_add_case_references_character_limit_exceeded(self, references_handler):
assert success is False
assert "exceeds 2000 character limit" in error

def test_add_case_references_deduplication(self, references_handler):
"""Test that duplicate references in input are deduplicated"""
# Mock get_case response with existing refs
mock_get_case_response = APIClientResult(
status_code=200,
response_text={
"id": 1,
"title": "Test Case 1",
"refs": "REQ-1"
},
error_message=None
)

# Mock update_case response
mock_update_response = APIClientResult(
status_code=200,
response_text={"id": 1, "refs": "REQ-1,REQ-2,REQ-3"},
error_message=None
)

with patch.object(references_handler.client, 'send_get', return_value=mock_get_case_response), \
patch.object(references_handler.client, 'send_post', return_value=mock_update_response):

success, error = references_handler.add_case_references(
case_id=1,
references=["REQ-2", "REQ-2", "REQ-3", "REQ-2"] # Duplicates should be removed
)

assert success is True
assert error == ""

# Verify the API call has deduplicated references
references_handler.client.send_post.assert_called_once_with(
"update_case/1",
{'refs': 'REQ-1,REQ-2,REQ-3'} # Duplicates removed, order preserved
)

def test_update_case_references_success(self, references_handler):
"""Test successful update of references on a test case"""
# Mock update_case response
Expand Down Expand Up @@ -212,8 +249,8 @@ def test_update_case_references_success(self, references_handler):

def test_update_case_references_character_limit_exceeded(self, references_handler):
"""Test character limit validation for update"""
# Try to update with refs that exceed 2000 chars
long_refs = ["REQ-" + "X" * 500 for _ in range(5)]
# Try to update with refs that exceed 2000 chars (using unique refs to account for deduplication)
long_refs = [f"REQ-{i}-" + "X" * 500 for i in range(5)]

success, error = references_handler.update_case_references(
case_id=1,
Expand All @@ -223,6 +260,31 @@ def test_update_case_references_character_limit_exceeded(self, references_handle
assert success is False
assert "exceeds 2000 character limit" in error

def test_update_case_references_deduplication(self, references_handler):
"""Test that duplicate references in input are deduplicated"""
# Mock update_case response
mock_update_response = APIClientResult(
status_code=200,
response_text={"id": 1, "refs": "REQ-1,REQ-2"},
error_message=None
)

with patch.object(references_handler.client, 'send_post', return_value=mock_update_response):

success, error = references_handler.update_case_references(
case_id=1,
references=["REQ-1", "REQ-1", "REQ-2", "REQ-1"] # Duplicates should be removed
)

assert success is True
assert error == ""

# Verify the API call has deduplicated references
references_handler.client.send_post.assert_called_once_with(
"update_case/1",
{'refs': 'REQ-1,REQ-2'} # Duplicates removed, order preserved
)

def test_update_case_references_api_failure(self, references_handler):
"""Test API failure during update"""
# Mock update_case response with failure
Expand Down
Loading