11# pylint: disable=invalid-name,protected-access,too-many-lines,unused-argument
22import unittest
3- from unittest .mock import MagicMock
3+ from unittest .mock import MagicMock , call
44
55from python import scraper_config
66
@@ -201,14 +201,14 @@ def test_configure_tags__true(self):
201201 tags = ["tag 1" , "tag 2" ]
202202 input_details = {'info' : {'tag' : tags }}
203203 input_settings = MagicMock (spec = ['getSettingBool' ])
204- input_settings .getSettingBool .return_value = True
204+ input_settings .getSettingBool .side_effect = [ True , False ]
205205
206206 expected_output = {'info' : {'tag' : tags }}
207207
208208 actual_output = scraper_config ._configure_tags (input_details , input_settings )
209209
210210 self .assertListEqual (expected_output ['info' ]['tag' ], actual_output ['info' ]['tag' ])
211- input_settings .getSettingBool .assert_called_once_with ( 'add_tags' )
211+ input_settings .getSettingBool .assert_has_calls ([ call ( 'add_tags' ), call ( 'enable_tag_whitelist' )] )
212212
213213 def test_configure_tags__false (self ):
214214 input_details = {'info' : {'tag' : ["tag 1" , "tag 2" ]}}
@@ -222,6 +222,21 @@ def test_configure_tags__false(self):
222222 self .assertDictEqual (expected_output ['info' ], actual_output ['info' ])
223223 input_settings .getSettingBool .assert_called_once_with ('add_tags' )
224224
225+ def test_configure_tags__whitelist (self ):
226+ tags = ["tag 1" , "tag 2" ]
227+ input_details = {'info' : {'tag' : tags }}
228+ input_settings = MagicMock (spec = ['getSettingBool' , 'getStringList' ])
229+ input_settings .getSettingBool .return_value = True
230+ input_settings .getStringList .return_value = ["tag 1" , "tag 3" ]
231+
232+ expected_output = {'info' : {'tag' : ["tag 1" ]}}
233+
234+ actual_output = scraper_config ._configure_tags (input_details , input_settings )
235+
236+ self .assertListEqual (expected_output ['info' ]['tag' ], actual_output ['info' ]['tag' ])
237+ input_settings .getSettingBool .assert_has_calls ([call ('add_tags' ), call ('enable_tag_whitelist' )])
238+ input_settings .getStringList .assert_called_once_with ('tag_whitelist' )
239+
225240
226241class TestPathSpecificSettings (unittest .TestCase ):
227242 def test_getSettingString (self ):
0 commit comments