@@ -0,0 +1,1897 @@
+# -*- coding: utf-8 -*-%0A%0A# Import future libs%0Afrom __future__ import absolute_import, print_function, unicode_literals%0A%0A# Import Salt Testing libs%0Afrom tests.support.mixins import LoaderModuleMockMixin%0Afrom tests.support.unit import TestCase%0Afrom tests.support.mock import MagicMock, patch%0A%0A# Import salt module%0Aimport salt.modules.tomcat as tomcat%0A%0A# Import 3rd-party libs%0Afrom io import StringIO, BytesIO%0A%0Aclass TomcatTestCasse(TestCase, LoaderModuleMockMixin):%0A    '''%0A    Tests cases for salt.modules.tomcat%0A    '''%0A    def setup_loader_modules(self):%0A        return %7Btomcat: %7B%7D%7D%0A%0A%0A    def test_tomcat_wget_no_bytestring(self):%0A        responses = %7B%0A            'string': StringIO('Best response ever%5Cr%5CnAnd you know it!'),%0A            'bytes': BytesIO(b'Best response ever%5Cr%5CnAnd you know it!')%0A        %7D%0A%0A        string_mock= MagicMock(return_value=responses%5B'string'%5D)%0A        bytes_mock= MagicMock(return_value=responses%5B'bytes'%5D)%0A        with patch('salt.modules.tomcat._auth', MagicMock(return_value=True)):%0A            with patch('salt.modules.tomcat._urlopen', string_mock):%0A                response = tomcat._wget('tomcat.wait', url='http://localhost:8080/nofail')%0A                for line in response%5B'msg'%5D:%0A                    self.assertEqual(type(line).__name__, 'str')%0A%0A            with patch('salt.modules.tomcat._urlopen', bytes_mock):%0A                try:%0A                    response = tomcat._wget('tomcat.wait', url='http://localhost:8080/nofail')%0A                except TypeError as type_error:%0A                    if type_error.args%5B0%5D == 'startswith first arg must be bytes or a tuple of bytes, not str':%0A                        self.fail('Got back a byte string, should%5C've been a string')%0A                    else:%0A                        raise type_error%0A%0A                for line in response%5B'msg'%5D:%0A                    self.assertEqual(type(line).__name__, 'str')%0A

Add unit test for _wget method in tomcat module