@@ -20,6 +20,22 @@ def get_input_stream():
20
20
]
21
21
22
22
23
+ @pytest .fixture
24
+ def get_input_stream_with_linked_field ():
25
+ return [
26
+ {
27
+ "row" : {
28
+ "prefix" : "article-4-direction-area" ,
29
+ "reference" : "1" ,
30
+ "organisation" : "local-authority:ABC" ,
31
+ "article-4-direction" : "a4d2" ,
32
+ },
33
+ "entry-number" : 1 ,
34
+ "line-number" : 2 ,
35
+ }
36
+ ]
37
+
38
+
23
39
@pytest .fixture
24
40
def get_lookup ():
25
41
return {",dataset,1,test" : "1" }
@@ -124,19 +140,10 @@ def test_process_empty_prefix(self, get_lookup):
124
140
125
141
assert output [0 ]["row" ]["entity" ] == "10"
126
142
127
- def test_no_associated_documents_issue (self , mocker ):
128
- input_stream = [
129
- {
130
- "row" : {
131
- "prefix" : "article-4-direction-area" ,
132
- "reference" : "1" ,
133
- "organisation" : "local-authority:ABC" ,
134
- "article-4-direction" : "a4d2" ,
135
- },
136
- "entry-number" : 1 ,
137
- "line-number" : 2 ,
138
- }
139
- ]
143
+ def test_no_associated_documents_issue (
144
+ self , get_input_stream_with_linked_field , mocker
145
+ ):
146
+ input_stream = get_input_stream_with_linked_field
140
147
141
148
lookups = {
142
149
",article-4-direction,a4d1,local-authorityabc" : "1" ,
@@ -157,19 +164,10 @@ def test_no_associated_documents_issue(self, mocker):
157
164
)
158
165
assert issues .rows [0 ]["value" ] == "a4d2"
159
166
160
- def test_no_associated_documents_issue_for_missing_dataset (self , mocker ):
161
- input_stream = [
162
- {
163
- "row" : {
164
- "prefix" : "article-4-direction-area" ,
165
- "reference" : "1" ,
166
- "organisation" : "local-authority:ABC" ,
167
- "article-4-direction" : "a4d2" ,
168
- },
169
- "entry-number" : 1 ,
170
- "line-number" : 2 ,
171
- }
172
- ]
167
+ def test_no_associated_documents_issue_for_missing_dataset (
168
+ self , get_input_stream_with_linked_field , mocker
169
+ ):
170
+ input_stream = get_input_stream_with_linked_field
173
171
174
172
lookups = {
175
173
",article-4-direction,a4d1,local-authorityabc" : "1" ,
@@ -186,6 +184,33 @@ def test_no_associated_documents_issue_for_missing_dataset(self, mocker):
186
184
assert output [0 ]["row" ]["entity" ] == "2"
187
185
assert len (issues .rows ) == 0
188
186
187
+ def test_no_associated_documents_issue_for_retired_entity (
188
+ self , get_input_stream_with_linked_field , mocker
189
+ ):
190
+ input_stream = get_input_stream_with_linked_field
191
+
192
+ lookups = {
193
+ ",article-4-direction,a4d2,local-authorityabc" : "1" ,
194
+ ",article-4-direction-area,1,local-authorityabc" : "2" ,
195
+ }
196
+ issues = IssueLog ()
197
+ redirect_lookups = {"1" : {"entity" : "" , "status" : "410" }}
198
+
199
+ phase = LookupPhase (
200
+ lookups = lookups , redirect_lookups = redirect_lookups , issue_log = issues
201
+ )
202
+ phase .entity_field = "entity"
203
+ mock_df = pd .DataFrame ({"organisation" : ["local-authority:ABC" ]})
204
+ mocker .patch ("pandas.read_csv" , return_value = mock_df )
205
+ output = [block for block in phase .process (input_stream )]
206
+
207
+ assert output [0 ]["row" ]["entity" ] == "2"
208
+ assert (
209
+ issues .rows [0 ]["issue-type" ]
210
+ == "no associated documents found for this area"
211
+ )
212
+ assert issues .rows [0 ]["value" ] == "a4d2"
213
+
189
214
190
215
class TestPrintLookupPhase :
191
216
def test_process_does_not_produce_new_lookup (self , get_input_stream , get_lookup ):
0 commit comments