Skip to content

Commit dfb32f7

Browse files
committed
chores: small code changes to improve code coverage
1 parent 3535ba8 commit dfb32f7

3 files changed

Lines changed: 9 additions & 27 deletions

File tree

sw360/attachments.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,10 @@ def get_attachment_infos_for_resource(self, resource_type: str, resource_id: str
5555
+ "/attachments"
5656
)
5757

58-
if not resp:
59-
return []
58+
if resp and "_embedded" in resp and "sw360:attachments" in resp["_embedded"]:
59+
return resp["_embedded"]["sw360:attachments"]
6060

61-
if "_embedded" not in resp:
62-
return []
63-
64-
if "sw360:attachments" not in resp["_embedded"]:
65-
return []
66-
67-
return resp["_embedded"]["sw360:attachments"]
61+
return []
6862

6963
def get_attachment_infos_for_release(self, release_id: str) -> List[Dict[str, Any]]:
7064
"""Get information about the attachments of a release

sw360/license.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,10 @@ def get_all_licenses(self) -> List[Dict[str, Any]]:
117117
"""
118118

119119
resp = self.api_get(self.url + "resource/api/licenses")
120-
if not resp:
121-
return []
120+
if resp and "_embedded" in resp and "sw360:licenses" in resp["_embedded"]:
121+
return resp["_embedded"]["sw360:licenses"]
122122

123-
if "_embedded" not in resp:
124-
return []
125-
126-
if "sw360:licenses" not in resp["_embedded"]:
127-
return []
128-
129-
return resp["_embedded"]["sw360:licenses"]
123+
return []
130124

131125
def get_license(self, license_id: str) -> Optional[Dict[str, Any]]:
132126
"""Get information of about a license

sw360/vendor.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,10 @@ def get_all_vendors(self) -> List[Dict[str, Any]]:
2727
"""
2828

2929
resp = self.api_get(self.url + "resource/api/vendors")
30-
if not resp:
31-
return []
30+
if resp and "_embedded" in resp and "sw360:vendors" in resp["_embedded"]:
31+
return resp["_embedded"]["sw360:vendors"]
3232

33-
if "_embedded" not in resp:
34-
return []
35-
36-
if "sw360:vendors" not in resp["_embedded"]:
37-
return []
38-
39-
return resp["_embedded"]["sw360:vendors"]
33+
return []
4034

4135
def get_vendor(self, vendor_id: str) -> Optional[Dict[str, Any]]:
4236
"""Returns a vendor

0 commit comments

Comments
 (0)