-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: BCPs can normatively cite all other standards levels (#6530)
* fix: BCPs can normatively cite all other standards levels Fixes #6524 * Revise the logic and add tests * Fix bug in truth table
- Loading branch information
1 parent
601ab53
commit 6d87279
Showing
2 changed files
with
146 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# Copyright The IETF Trust 2016-2023, All Rights Reserved | ||
# -*- coding: utf-8 -*- | ||
|
||
import itertools | ||
|
||
from ietf.doc.factories import WgRfcFactory | ||
from ietf.doc.models import RelatedDocument | ||
from ietf.utils.test_utils import TestCase | ||
|
||
|
||
class RelatedDocumentTests(TestCase): | ||
def test_is_downref(self): | ||
rfcs = [ | ||
WgRfcFactory(std_level_id=lvl) | ||
for lvl in ["inf", "exp", "bcp", "ps", "ds", "std", "unkn"] | ||
] | ||
|
||
result_matrix = { | ||
# source | ||
"inf": { | ||
"inf": None, # target | ||
"exp": None, # target | ||
"bcp": None, # target | ||
"ps": None, # target | ||
"ds": None, # target | ||
"std": None, # target | ||
"unkn": None, # target | ||
}, | ||
# source | ||
"exp": { | ||
"inf": None, # target | ||
"exp": None, # target | ||
"bcp": None, # target | ||
"ps": None, # target | ||
"ds": None, # target | ||
"std": None, # target | ||
"unkn": None, # target | ||
}, | ||
# source | ||
"bcp": { | ||
"inf": "Downref", # target | ||
"exp": "Downref", # target | ||
"bcp": None, # target | ||
"ps": None, # target | ||
"ds": None, # target | ||
"std": None, # target | ||
"unkn": "Possible Downref", # target | ||
}, | ||
# source | ||
"ps": { | ||
"inf": "Downref", # target | ||
"exp": "Downref", # target | ||
"bcp": None, # target | ||
"ps": None, # target | ||
"ds": None, # target | ||
"std": None, # target | ||
"unkn": "Possible Downref", # target | ||
}, | ||
# source | ||
"ds": { | ||
"inf": "Downref", # target | ||
"exp": "Downref", # target | ||
"bcp": None, # target | ||
"ps": "Downref", # target | ||
"ds": None, # target | ||
"std": None, # target | ||
"unkn": "Possible Downref", # target | ||
}, | ||
# source | ||
"std": { | ||
"inf": "Downref", # target | ||
"exp": "Downref", # target | ||
"bcp": None, # target | ||
"ps": "Downref", # target | ||
"ds": "Downref", # target | ||
"std": None, # target | ||
"unkn": "Possible Downref", # target | ||
}, | ||
# source | ||
"unkn": { | ||
"inf": None, # target | ||
"exp": None, # target | ||
"bcp": None, # target | ||
"ps": "Possible Downref", # target | ||
"ds": "Possible Downref", # target | ||
"std": None, # target | ||
"unkn": "Possible Downref", # target | ||
}, | ||
} | ||
|
||
for rel in ["refnorm", "refinfo", "refunk", "refold"]: | ||
for source, target in itertools.product(rfcs, rfcs): | ||
ref = RelatedDocument.objects.create( | ||
source=source, | ||
target=target.docalias.first(), | ||
relationship_id=rel, | ||
) | ||
|
||
result = ref.is_downref() | ||
|
||
desired_result = ( | ||
result_matrix[source.std_level_id][target.std_level_id] | ||
if ref.relationship.slug in ["refnorm", "refunk"] | ||
else None | ||
) | ||
if ( | ||
ref.relationship.slug == "refunk" | ||
and desired_result is not None | ||
and not desired_result.startswith("Possible") | ||
): | ||
desired_result = f"Possible {desired_result}" | ||
|
||
self.assertEqual(desired_result, result) |