forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests_models.py
More file actions
113 lines (104 loc) · 3.77 KB
/
tests_models.py
File metadata and controls
113 lines (104 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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,
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)