Example #1
0
 def test_get_dtd_content(self):
     url = 'http://xmltool.lereskp.fr/static/exercise.dtd'
     http_content = utils.get_dtd_content(url)
     url = 'tests/exercise.dtd'
     fs_content = utils.get_dtd_content(url)
     self.assertEqual(http_content, fs_content)
     url = 'exercise.dtd'
     fs_content = utils.get_dtd_content(url, path='tests/')
     self.assertEqual(http_content, fs_content)
Example #2
0
 def test_get_dtd_content(self):
     url = 'http://xmltool.lereskp.fr/static/exercise.dtd'
     http_content = utils.get_dtd_content(url)
     url = 'tests/exercise.dtd'
     fs_content = utils.get_dtd_content(url)
     self.assertEqual(http_content, fs_content)
     url = 'exercise.dtd'
     fs_content = utils.get_dtd_content(url, path='tests/')
     self.assertEqual(http_content, fs_content)
Example #3
0
    def test_get_dtd_content(self):
        url = 'tests/exercise.dtd'
        content = utils.get_dtd_content(url)

        with mock.patch('xmltool.utils._get_dtd_content',
                        return_value='my content'):
            content = utils.get_dtd_content(url)
            self.assertEqual(content, 'my content')

        cache.CACHE_TIMEOUT = 3600
        try:
            with mock.patch('xmltool.utils._get_dtd_content',
                            return_value='my content'):
                content = utils.get_dtd_content(url)
                self.assertEqual(content, 'my content')

            with mock.patch('xmltool.utils._get_dtd_content',
                            return_value='my new content'):
                content = utils.get_dtd_content(url)
                self.assertEqual(content, 'my content')
        finally:
            cache.CACHE_TIMEOUT = None