From 21052d1c1f14898008f0d52f41f0e76ad32d5ffd Mon Sep 17 00:00:00 2001 From: "Tannaz Vahidi (ext.)" Date: Thu, 1 Aug 2024 16:29:58 +0200 Subject: [PATCH] Codebeamer-lobster supports CB-API V3 The used codebeamer endpoints are updated and one unit-test has been added. Resolves #49 --- CHANGELOG.md | 7 ++++++- lobster/tools/codebeamer/codebeamer.py | 10 ++++++---- test-unit/lobster-codebeamer/test_codebeamer.py | 7 +++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fed5ba5a..f406817d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,12 @@ This allows to have multiple json elements with the same name in different source files -* The `lobster-codebeamer` tool now uses codebeamer api v3 +* The `lobster-codebeamer` tool now uses codebeamer api v3. + Please note that the api v3 returns the value "Unset" for a codebeamer + item status if the status is actually empty. The api v1 did not return + any value at all for an item with a missing status. This means that the + resulting lobster file will now contain "Unset" as status information, + too, instead of `Null`. * The `lobster-html-report` tool now supports argument `--dot` to specify the path to the graphviz dot utility instead of expecting it in PATH diff --git a/lobster/tools/codebeamer/codebeamer.py b/lobster/tools/codebeamer/codebeamer.py index a41fde26..a7e49f0b 100755 --- a/lobster/tools/codebeamer/codebeamer.py +++ b/lobster/tools/codebeamer/codebeamer.py @@ -82,7 +82,8 @@ def query_cb_single(cb_config, url): def get_single_item(cb_config, item_id): assert isinstance(item_id, int) and item_id > 0 - url = "%s/items/%u" % (cb_config["base"], item_id) + url = "%s/items/%u" % (cb_config["base"], + item_id) data = query_cb_single(cb_config, url) return data @@ -157,8 +158,9 @@ def to_lobster(cb_config, cb_item): # This looks like it's business logic, maybe we should make this # configurable? - if "typeName" in cb_item: - kind = cb_item["typeName"] + categories = cb_item.get("categories") + if categories: + kind = categories[0].get("name", "codebeamer item") else: kind = "codebeamer item" @@ -201,7 +203,7 @@ def import_tagged(mh, cb_config, items_to_import): assert isinstance(mh, Message_Handler) assert isinstance(cb_config, dict) assert isinstance(items_to_import, set) - rv = [] + rv = [] cb_items = get_many_items(cb_config, items_to_import) for cb_item in cb_items: diff --git a/test-unit/lobster-codebeamer/test_codebeamer.py b/test-unit/lobster-codebeamer/test_codebeamer.py index 6bdb6a31..9405acce 100644 --- a/test-unit/lobster-codebeamer/test_codebeamer.py +++ b/test-unit/lobster-codebeamer/test_codebeamer.py @@ -9,7 +9,6 @@ class QueryCodebeamerTest(unittest.TestCase): - def _assertListEqualByAttributes(self, list1, list2): self.assertEqual(len(list1), len(list2), "Lists length are not the same") for obj1, obj2 in zip(list1, list2): @@ -63,7 +62,7 @@ def test_import_tagged(self, mock_get): { 'id': 24406947, 'name': 'Test name 1', - 'typeName': 'Requirement', + 'categories': [{'name': 'Folder'}], 'version': 7, 'status': {'name': 'status'}, 'tracker': {'id': 123} @@ -71,7 +70,7 @@ def test_import_tagged(self, mock_get): { 'id': 21747817, 'name': 'Test name 2', - 'typeName': 'Requirement', + 'categories': [{'name': 'Folder'}], 'version': 10, 'status': {'name': 'status'}, 'tracker': {'id': 123} @@ -93,4 +92,4 @@ def test_import_tagged(self, mock_get): if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main()