Skip to content

Commit

Permalink
Fix part of the failing unit tests #3
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Dec 20, 2023
1 parent 3bcaf2e commit ecc3da4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@

{% if compliance_errors %}
<script>
$('.toggle-details')
.tooltip({container: 'body', placement: 'top'})
.on('click', function() {
$('.extra-details').toggle();
});

const tabInventoryLabel = document.getElementById('tab_inventory-tab');
if (tabInventoryLabel) {
var iconElement = document.createElement('i');
Expand Down
14 changes: 7 additions & 7 deletions product_portfolio/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def test_product_portfolio_detail_view_review_status_filter_in_inventory_tab(sel
dataspace=self.dataspace,
)

url = self.product1.get_absolute_url()
url = self.product1.get_url("tab_inventory")
response = self.client.get(url)

self.assertContains(response, self.component1.name)
Expand All @@ -344,9 +344,7 @@ def test_product_portfolio_detail_view_review_status_filter_in_inventory_tab(sel
self.assertContains(response, expected2)

response = self.client.get(url, data={"inventory-review_status": status1.label})
pc_filterset = response.context["tabsets"]["Inventory"]["fields"][0][1]["inventory_items"][
""
]
pc_filterset = response.context["inventory_items"][""]
self.assertIn(pc1, pc_filterset)
self.assertNotIn(pc2, pc_filterset)
self.assertIn(pp1, pc_filterset)
Expand Down Expand Up @@ -438,7 +436,7 @@ def test_product_portfolio_detail_view_inventory_tab_purpose_icon(self):
dataspace=self.dataspace,
)

url = self.product1.get_absolute_url()
url = self.product1.get_url("tab_inventory")
response = self.client.get(url)
expected = (
'<div class="text-nowrap">'
Expand All @@ -458,7 +456,7 @@ def test_product_portfolio_detail_view_inventory_tab_display_scan_features(
self.assertFalse(self.super_user.dataspace.enable_package_scanning)
mock_fetch_scan_list.return_value = None

url = self.product1.get_absolute_url()
url = self.product1.get_url("tab_inventory")
expected1 = "#scan-package-modal"
expected2 = "Submit Scan Request"
response = self.client.get(url)
Expand All @@ -472,8 +470,10 @@ def test_product_portfolio_detail_view_inventory_tab_display_scan_features(
response = self.client.get(url)
mock_fetch_scan_list.assert_not_called()
self.assertNotContains(response, expected1)
self.assertContains(response, expected2) # Since enable_package_scanning=True
self.assertNotContains(response, expected2)

self.package1.download_url = "https://download_url.value"
self.package1.save()
ProductPackage.objects.create(
product=self.product1, package=self.package1, dataspace=self.dataspace
)
Expand Down
5 changes: 2 additions & 3 deletions product_portfolio/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ def get_context_data(self, **kwargs):

if include_scancodeio_features:
context["pull_project_data_form"] = PullProjectDataForm()
context["display_scan_features"] = True

context["purldb_enabled"] = all(
[
Expand All @@ -565,8 +566,6 @@ def get_context_data(self, **kwargs):
]
)

context["display_scan_features"] = getattr(self, "display_scan_features", False)

return context


Expand Down Expand Up @@ -658,7 +657,7 @@ def get_context_data(self, **kwargs):
]
)
if display_scan_features:
self.display_scan_features = True
context["display_scan_features"] = True
self.inject_scan_data(scancodeio, objects_by_feature, dataspace.uuid)

# 5. Display the compliance alert based on license policies
Expand Down

0 comments on commit ecc3da4

Please sign in to comment.