From 25ca9e9b4703ffcb2add50e6e0b6e32a2f2c13f7 Mon Sep 17 00:00:00 2001 From: Marsel Mavletkulov Date: Fri, 30 Aug 2024 11:48:17 -0400 Subject: [PATCH] Add a link to reason codes --- minfraud/models.py | 8 ++++---- tests/data/factors-response.json | 2 +- tests/test_models.py | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/minfraud/models.py b/minfraud/models.py index 0350a42..222bf37 100644 --- a/minfraud/models.py +++ b/minfraud/models.py @@ -1082,7 +1082,8 @@ class Reason: This class provides both a machine-readable code and a human-readable explanation of the reason for the risk score. - Although more codes may be added in the future, the current codes are: + Although more `codes `_ # pylint: disable=line-too-long # noqa: E501 + may be added in the future, the current codes are: - ``BROWSER_LANGUAGE`` - Riskiness of the browser user-agent and language associated with the request. @@ -1329,9 +1330,8 @@ class Factors: .. attribute:: risk_score_reasons This tuple contains :class:`.RiskScoreReason` objects that describe - risk score reasons for a given transaction - that change the risk score significantly. - Risk score reasons are usually only returned for medium to + risk score reasons for a given transaction that change the risk score + significantly. Risk score reasons are usually only returned for medium to high risk transactions. If there were no significant changes to the risk score due to these reasons, then this tuple will be empty. diff --git a/tests/data/factors-response.json b/tests/data/factors-response.json index 2eef520..0b69b24 100644 --- a/tests/data/factors-response.json +++ b/tests/data/factors-response.json @@ -207,7 +207,7 @@ ], "risk_score_reasons": [ { - "multiplier": 45, + "multiplier": 45.0, "reasons": [ { "code": "ANONYMOUS_IP", diff --git a/tests/test_models.py b/tests/test_models.py index c0bc0b1..b42bacb 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -432,7 +432,9 @@ def check_insights_data(self, insights, uuid): ) def check_risk_score_reasons_data(self, reasons): + self.assertEqual(1, len(reasons)) self.assertEqual(45, reasons[0].multiplier) + self.assertEqual(1, len(reasons[0].reasons)) self.assertEqual("ANONYMOUS_IP", reasons[0].reasons[0].code) self.assertEqual( "Risk due to IP being an Anonymous IP", reasons[0].reasons[0].reason