Cover the required compatibility status and the contact statuses (section 23.1)
This commit is contained in:
1 parent
b99b2854f2
commit
cc72a51cdd
1 file changed
+57
-12
+57
-12
@@ -46,7 +46,7 @@ def sample_payload(key_number=1, wallet_software=None):
|
|||||||
"software_version": "1.8.0",
|
"software_version": "1.8.0",
|
||||||
"software_compatibility_status": "OK",
|
"software_compatibility_status": "OK",
|
||||||
"software_comments": "",
|
"software_comments": "",
|
||||||
"contact_info_verified": 1,
|
"contact_info_verified": "Confirmed current",
|
||||||
"comments": "Annual review",
|
"comments": "Annual review",
|
||||||
"key_check": entry,
|
"key_check": entry,
|
||||||
"tool_checks": [
|
"tool_checks": [
|
||||||
@@ -74,7 +74,7 @@ def unavailable_payload(key_number=1):
|
|||||||
"checked_at": "2026-10-01",
|
"checked_at": "2026-10-01",
|
||||||
"wallet_software": None,
|
"wallet_software": None,
|
||||||
"software_compatibility_status": "NOT_ASSESSED",
|
"software_compatibility_status": "NOT_ASSESSED",
|
||||||
"contact_info_verified": 1,
|
"contact_info_verified": "Needs external update",
|
||||||
"comments": "Annual review",
|
"comments": "Annual review",
|
||||||
"key_check": entry,
|
"key_check": entry,
|
||||||
"tool_checks": [],
|
"tool_checks": [],
|
||||||
@@ -139,18 +139,70 @@ class ValidationTests(unittest.TestCase):
|
|||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
validate_health_check(payload, KEYS)
|
validate_health_check(payload, KEYS)
|
||||||
|
|
||||||
def test_general_status_accepts_not_assessed_and_rejects_the_norwegian_value(self):
|
def test_compatibility_status_requires_an_explicit_choice(self):
|
||||||
payload = sample_payload()
|
# "not assessed" is no longer submittable for a new registration
|
||||||
|
# (section 23.1).
|
||||||
|
for value in ("", None, "NOT_ASSESSED", "IKKJE_VURDERT"):
|
||||||
|
payload = sample_payload()
|
||||||
|
payload["software_compatibility_status"] = value
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
validate_health_check(payload, KEYS)
|
||||||
|
|
||||||
|
def test_compatibility_status_accepts_ok_and_problem(self):
|
||||||
|
for value in ("OK", "PROBLEM"):
|
||||||
|
payload = sample_payload()
|
||||||
|
payload["software_compatibility_status"] = value
|
||||||
|
self.assertEqual(
|
||||||
|
validate_health_check(payload, KEYS)["software_compatibility_status"],
|
||||||
|
value,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_cloud_key_compatibility_is_derived_from_availability(self):
|
||||||
|
payload = sample_payload(key_number=3)
|
||||||
|
payload["software_compatibility_status"] = "OK"
|
||||||
|
self.assertEqual(
|
||||||
|
validate_health_check(payload, KEYS)["software_compatibility_status"],
|
||||||
|
"OK",
|
||||||
|
)
|
||||||
|
|
||||||
|
for value in ("PROBLEM", "NOT_ASSESSED"):
|
||||||
|
payload = sample_payload(key_number=3)
|
||||||
|
payload["software_compatibility_status"] = value
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
validate_health_check(payload, KEYS)
|
||||||
|
|
||||||
|
def test_unavailable_key_keeps_the_derived_compatibility(self):
|
||||||
|
payload = unavailable_payload()
|
||||||
payload["software_compatibility_status"] = "NOT_ASSESSED"
|
payload["software_compatibility_status"] = "NOT_ASSESSED"
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
validate_health_check(payload, KEYS)["software_compatibility_status"],
|
validate_health_check(payload, KEYS)["software_compatibility_status"],
|
||||||
"NOT_ASSESSED",
|
"NOT_ASSESSED",
|
||||||
)
|
)
|
||||||
|
|
||||||
payload["software_compatibility_status"] = "IKKJE_VURDERT"
|
payload["software_compatibility_status"] = "OK"
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
validate_health_check(payload, KEYS)
|
validate_health_check(payload, KEYS)
|
||||||
|
|
||||||
|
def test_contact_status_uses_the_two_stored_values(self):
|
||||||
|
for value in ("Confirmed current", "Needs external update"):
|
||||||
|
payload = sample_payload()
|
||||||
|
payload["contact_info_verified"] = value
|
||||||
|
self.assertEqual(
|
||||||
|
validate_health_check(payload, KEYS)["contact_info_verified"], value
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_contact_status_is_optional_and_never_a_flag(self):
|
||||||
|
payload = sample_payload()
|
||||||
|
payload["contact_info_verified"] = ""
|
||||||
|
self.assertIsNone(validate_health_check(payload, KEYS)["contact_info_verified"])
|
||||||
|
|
||||||
|
# The old 0/1 flag is no longer a valid value (section 23.1).
|
||||||
|
for value in (1, 0, True, "yes"):
|
||||||
|
payload = sample_payload()
|
||||||
|
payload["contact_info_verified"] = value
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
validate_health_check(payload, KEYS)
|
||||||
|
|
||||||
def test_standards_status_accepts_yes_no_and_not_assessed(self):
|
def test_standards_status_accepts_yes_no_and_not_assessed(self):
|
||||||
for field in ("bip327_status", "slip39_status"):
|
for field in ("bip327_status", "slip39_status"):
|
||||||
for value in ("YES", "NO", "NOT_ASSESSED"):
|
for value in ("YES", "NO", "NOT_ASSESSED"):
|
||||||
@@ -317,13 +369,6 @@ class ValidationTests(unittest.TestCase):
|
|||||||
self.assertEqual(result["software_compatibility_status"], "NOT_ASSESSED")
|
self.assertEqual(result["software_compatibility_status"], "NOT_ASSESSED")
|
||||||
self.assertEqual(result["key_check"]["comments"], "Key is with the third holder")
|
self.assertEqual(result["key_check"]["comments"], "Key is with the third holder")
|
||||||
|
|
||||||
def test_invalid_flag_is_rejected(self):
|
|
||||||
payload = sample_payload()
|
|
||||||
payload["contact_info_verified"] = "yes"
|
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
|
||||||
validate_health_check(payload, KEYS)
|
|
||||||
|
|
||||||
def test_over_long_text_is_rejected(self):
|
def test_over_long_text_is_rejected(self):
|
||||||
payload = sample_payload()
|
payload = sample_payload()
|
||||||
payload["comments"] = "x" * 4001
|
payload["comments"] = "x" * 4001
|
||||||
|
|||||||
Reference in new issue
Block a user