|
1 | | -# Copyright 2013-2020 CDPedistas (see AUTHORS.txt) |
| 1 | +# Copyright 2013-2021 CDPedistas (see AUTHORS.txt) |
2 | 2 | # |
3 | 3 | # This program is free software: you can redistribute it and/or modify it |
4 | 4 | # under the terms of the GNU General Public License version 3, as published |
@@ -199,6 +199,28 @@ def test_empty_dir(self, tmp_path, wikisite): |
199 | 199 | ws.commit() |
200 | 200 | assert os.path.getsize(config.LOG_PREPROCESADO) == 0 |
201 | 201 |
|
| 202 | + def test_transmit_redirection_score_to_destination(self, mocker, tmp_path, wikisite): |
| 203 | + """Test that extra scores produced while processing a redirection are not discarded.""" |
| 204 | + ws = wikisite(str(tmp_path)) |
| 205 | + |
| 206 | + # mock preprocessor that discards the redirection and transmits the score to destination |
| 207 | + omit_redirects = mocker.Mock(return_value=(None, [('destination', 1234)])) |
| 208 | + mocker.patch.object(ws, 'preprocessors', [omit_redirects]) |
| 209 | + |
| 210 | + # dummy redirection article that will be discarded |
| 211 | + article = tmp_path.joinpath('r', 'e', 'd', 'redirection') |
| 212 | + article.parent.mkdir(parents=True) |
| 213 | + article.touch() |
| 214 | + |
| 215 | + ws.process() |
| 216 | + ws.commit() |
| 217 | + |
| 218 | + with open(preprocess.LOG_SCORES_ACCUM, 'rt', encoding='utf-8') as fh: |
| 219 | + scores = fh.read() |
| 220 | + |
| 221 | + # real score of redirection is discarded, extra score of destination is saved |
| 222 | + assert scores == 'destination|E|1234\n' |
| 223 | + |
202 | 224 |
|
203 | 225 | class TestPagesSelector(object): |
204 | 226 | """Tests for the PagesSelector""" |
|
0 commit comments