@@ -1213,6 +1213,48 @@ def test_scanpipe_management_command_check_compliance(self):
12131213 )
12141214 self .assertEqual (expected , out_value )
12151215
1216+ def test_scanpipe_management_command_check_clarity_compliance_only (self ):
1217+ project = make_project (name = "my_project_clarity" )
1218+
1219+ project .extra_data = {"clarity_compliance_alert" : "error" }
1220+ project .save (update_fields = ["extra_data" ])
1221+
1222+ out = StringIO ()
1223+ options = ["--project" , project .name ]
1224+ with self .assertRaises (SystemExit ) as cm :
1225+ call_command ("check-compliance" , * options , stderr = out )
1226+ self .assertEqual (cm .exception .code , 1 )
1227+ out_value = out .getvalue ().strip ()
1228+ expected = (
1229+ "1 compliance issues detected."
1230+ "\n [License Clarity Compliance]\n > Alert Level: error"
1231+ )
1232+ self .assertEqual (expected , out_value )
1233+
1234+ def test_scanpipe_management_command_check_both_compliance_and_clarity (self ):
1235+ project = make_project (name = "my_project_both" )
1236+
1237+ make_package (
1238+ project ,
1239+ package_url = "pkg:generic/[email protected] " ,
1240+ compliance_alert = CodebaseResource .Compliance .ERROR ,
1241+ )
1242+ project .extra_data = {"clarity_compliance_alert" : "warning" }
1243+ project .save (update_fields = ["extra_data" ])
1244+
1245+ out = StringIO ()
1246+ options = ["--project" , project .name , "--fail-level" , "WARNING" ]
1247+ with self .assertRaises (SystemExit ) as cm :
1248+ call_command ("check-compliance" , * options , stderr = out )
1249+ self .assertEqual (cm .exception .code , 1 )
1250+ out_value = out .getvalue ().strip ()
1251+ expected = (
1252+ "2 compliance issues detected."
1253+ "\n [packages]\n > ERROR: 1"
1254+ "\n [License Clarity Compliance]\n > Alert Level: warning"
1255+ )
1256+ self .assertEqual (expected , out_value )
1257+
12161258 def test_scanpipe_management_command_check_compliance_vulnerabilities (self ):
12171259 project = make_project (name = "my_project" )
12181260 package1 = make_package (
project ,
package_url = "pkg:generic/[email protected] " )
0 commit comments