Skip to content

Commit

Permalink
Fix more of the failing tests #63
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Jun 27, 2024
1 parent d6d4fdc commit 178a12b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions component_catalog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2362,6 +2362,7 @@ def create_from_url(cls, url, user):
f"{url} already exists in your Dataspace as {package_link}"
)

# Duplicate the declared_license_expression into the license_expression field.
if declared_license_expression := package_data.get("declared_license_expression"):
package_data["license_expression"] = declared_license_expression

Expand Down
20 changes: 11 additions & 9 deletions component_catalog/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def test_component_catalog_detail_view_content(self):
self.assertContains(response, 'id="tab_hierarchy"')

# Legal tab is only displayed if one a the legal field is set
self.assertNotContains(response, 'id="tab_legal"')
self.component1.legal_comments = "Comments"
self.component1.save()
response = self.client.get(url)
Expand Down Expand Up @@ -2136,8 +2135,8 @@ def test_package_details_view_scan_tab_scan_success(

expected_declared_license = """
<span class="license-expression">
<input type="checkbox" name="license_expression" value="l1 AND l2 WITH e" checked>
<a href="/licenses/Dataspace/l1/" title="L1">l1</a>
<input type="checkbox" name="declared_license_expression" value="l1 AND l2 WITH e"
checked><a href="/licenses/Dataspace/l1/" title="L1">l1</a>
AND (<a href="/licenses/Dataspace/l2/" title="L2">l2</a>
WITH <a href="/licenses/Dataspace/e/" title="e">e</a>)
</span>
Expand All @@ -2149,7 +2148,7 @@ def test_package_details_view_scan_tab_scan_success(
'<input type="radio" name="primary_language" value="C++" checked> C++'
)
expected_other_licenses = """
<span class="license-expression"><input type="checkbox" name="license_expression"
<span class="license-expression"><input type="checkbox" name="other_license_expression"
value="mit" > mit <span class="badge text-bg-secondary rounded-pill">3</span></span>
"""
expected_other_holders = (
Expand Down Expand Up @@ -2450,12 +2449,14 @@ def test_package_details_view_scan_tab_license_matches(
}

expected1 = (
'<span class="license-expression"><input type="checkbox" name="license_expression" '
'<span class="license-expression"><input type="checkbox" '
'name="other_license_expression" '
'value="apache-2.0" > apache-2.0 <span class="badge text-bg-secondary rounded-pill">3'
"</span></span>"
)
expected2 = (
'<span class="license-expression"><input type="checkbox" name="license_expression" '
'<span class="license-expression"><input type="checkbox" '
'name="other_license_expression" '
'value="mit" > mit <span class="badge text-bg-secondary rounded-pill">2</span></span>'
)
response = self.client.get(self.package1_tab_scan_url)
Expand Down Expand Up @@ -2695,7 +2696,7 @@ def test_package_details_view_scan_summary_to_package(
self.assertEqual("The Rust Project Developers", self.package1.holder)

history = History.objects.get_for_object(self.package1, action_flag=History.CHANGE).get()
expected = "Concluded license expression, Primary language and Holder."
expected = "Changed Concluded license expression, Primary language and Holder."
self.assertEqual(expected, history.get_change_message())

response = self.client.post(url, post_data, follow=True)
Expand Down Expand Up @@ -2738,7 +2739,8 @@ def test_package_details_view_scan_summary_to_package_libc(
response = self.client.get(self.package1_tab_scan_url)
expected_license_expression_html = (
'<span class="license-expression">'
'<input type="checkbox" name="license_expression" value="apache-2.0 OR mit" checked> '
'<input type="checkbox" name="declared_license_expression" '
'value="apache-2.0 OR mit" checked> '
"apache-2.0 OR mit</span>"
)
expected_holder_html = (
Expand Down Expand Up @@ -2790,7 +2792,7 @@ def test_package_details_view_scan_summary_to_package_libc(
self.assertEqual(expected_holder, self.package1.holder)

history = History.objects.get_for_object(self.package1, action_flag=History.CHANGE).get()
expected = "Changed License expression, Primary language and Holder."
expected = "Changed Concluded license expression, Primary language and Holder."
self.assertEqual(expected, history.get_change_message())

response = self.client.post(url, post_data, follow=True)
Expand Down
2 changes: 1 addition & 1 deletion dje/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def test_manage_copy_defaults_view(self):
'<input type="checkbox" name="form-2-license" value="usage_policy" class="inline"'
' id="id_form-2-license_26" checked />',
'<input type="checkbox" name="form-3-component" value="usage_policy" class="inline"'
' id="id_form-3-component_45" checked />',
' id="id_form-3-component_46" checked />',
'<input type="checkbox" name="form-3-component" value="guidance" class="inline"'
' id="id_form-3-component_12" checked />',
'<input type="checkbox" name="form-3-subcomponent relationship" value="usage_policy"'
Expand Down

0 comments on commit 178a12b

Please sign in to comment.