Skip to content

Commit

Permalink
fix: the order of the links in grouped linked workitems should be stable
Browse files Browse the repository at this point in the history
  • Loading branch information
micha91 committed Nov 29, 2023
1 parent b9e24fd commit 996d17f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions capella2polarion/elements/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ def _make_url_list(

url = serialize.POLARION_WORK_ITEM_URL.format(pid=pid)
urls.append(f"<li>{url}</li>")

urls.sort()
url_list = "\n".join(urls)
return f"<ul>{url_list}</ul>"

Expand Down
19 changes: 19 additions & 0 deletions tests/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,25 @@ def test_maintain_reverse_grouped_links_attributes(dummy_work_items):
assert dummy_work_items["uuid2"].additional_attributes == {}


def test_grouped_linked_work_items_order_consistency():
work_item = serialize.CapellaWorkItem("id", "Dummy")
links = [
polarion_api.WorkItemLink("prim1", "id", "role1"),
polarion_api.WorkItemLink("prim2", "id", "role1"),
]
element.create_grouped_back_link_fields(work_item, links)

check_sum = work_item.calculate_checksum()

links = [
polarion_api.WorkItemLink("prim2", "id", "role1"),
polarion_api.WorkItemLink("prim1", "id", "role1"),
]
element.create_grouped_back_link_fields(work_item, links)

assert check_sum == work_item.calculate_checksum()


class TestHelpers:
@staticmethod
def test_resolve_element_type():
Expand Down

0 comments on commit 996d17f

Please sign in to comment.