<s> import mock <EOL> import testify as T <EOL> from pushmanager . testing . mocksettings import MockedSettings <EOL> from pushmanager . servlets . testtag import TestTagServlet <EOL> from pushmanager . core . settings import Settings <EOL> class TestTagServletTest ( T . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_generate_test_tag_normal ( self , mock_urlopen ) : <EOL> m = mock . Mock ( ) <EOL> m . read . side_effect = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> mock_urlopen . return_value = m <EOL> MockedSettings [ '<STR_LIT>' ] = { } <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT:test>' <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> request_info = { '<STR_LIT>' : '<STR_LIT:test>' , '<STR_LIT>' : '<STR_LIT:test>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> with mock . patch . dict ( Settings , MockedSettings ) : <EOL> gen_tags = TestTagServlet . _gen_test_tag_resp ( request_info ) <EOL> T . assert_equals ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : "<STR_LIT>" } , gen_tags ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_generate_test_tag_no_url ( self , mock_urlopen ) : <EOL> m = mock . Mock ( ) <EOL> m . read . side_effect = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> mock_urlopen . return_value = m <EOL> MockedSettings [ '<STR_LIT>' ] = { } <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT:test>' <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> MockedSettings [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> request_info = { '<STR_LIT>' : '<STR_LIT:test>' , '<STR_LIT>' : '<STR_LIT:test>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> with mock . patch . dict ( Settings , MockedSettings ) : <EOL> gen_tags = TestTagServlet . _gen_test_tag_resp ( request_info ) <EOL> T . assert_equals ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : "<STR_LIT>" } , gen_tags ) <EOL> def test_generate_test_tag_none ( self ) : <EOL> del MockedSettings [ '<STR_LIT>' ] <EOL> request_info = { '<STR_LIT>' : '<STR_LIT:test>' , '<STR_LIT>' : '<STR_LIT:test>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> with mock . patch . dict ( Settings , MockedSettings ) : <EOL> gen_tags = TestTagServlet . _gen_test_tag_resp ( request_info ) <EOL> T . assert_equals ( { } , gen_tags ) </s>
