Exemplo n.º 1
0
 def test_007_cache(self):
     """With a file it is downloaded and cached in a temporary file"""
     # TODO: Mock this
     downloaded = tools.cache_it(self.cadena_travis)
     hits = tools._cache_it.cache_info().hits
     new_downloaded = tools.cache_it(self.cadena_travis)
     new_hits = tools._cache_it.cache_info().hits
     self.assertEqual(new_hits - hits, 1, 'Cache was not cached properly')
     self.assertEqual(downloaded, new_downloaded, 'Cache different values')
     self.assertTrue(isfile(downloaded), 'Cache was not generate file')
Exemplo n.º 2
0
 def test_007_clear_cache(self):
     """With a cached tempfile deleted"""
     # TODO: Mock this
     downloaded = tools.cache_it(self.cadena_travis)
     unlink(downloaded)
     tools.cache_it(self.cadena_travis)
     hits = tools._cache_it.cache_info().hits
     self.assertFalse(hits, 'Cache was not cleared')
     tools.cache_it(self.cadena_travis)
     hits = tools._cache_it.cache_info().hits
     self.assertTrue(hits == 1, 'Cache hits not increased 1 after cleared')
Exemplo n.º 3
0
 def test_006_download_file(self):
     """With a file it is downloaded and cached in a temporary file"""
     # TODO: Mock this
     downloaded = tools.cache_it(self.cadena_travis)
     content = open(downloaded).read()
     self.assertTrue(content.find('se establece que la salida') > 0,
                     'I read the content of a cached file and '
                     'the result was not correct.')
Exemplo n.º 4
0
 def test_006_download_file(self):
     """With a file it is downloaded and cached in a temporary file"""
     # TODO: Mock this
     downloaded = tools.cache_it(
         'http://www.sat.gob.mx/sitio_internet/cfd/3/cadenaoriginal_3_2/cadenaoriginal_3_2.xslt')  # noqa
     content = open(downloaded).read()
     self.assertTrue(content.find('se establece que la salida') > 0,
                     'I read the content of a cached file and '
                     'the result was not correct.')
Exemplo n.º 5
0
 def test_006_download_file(self):
     """With a file it is downloaded and cached in a temporary file"""
     # TODO: Mock this
     downloaded = tools.cache_it(self.cadena_travis)
     content = open(downloaded).read()
     self.assertTrue(
         content.find('se establece que la salida') > 0,
         'I read the content of a cached file and '
         'the result was not correct.')
Exemplo n.º 6
0
 def test_006_xml2xslt(self):
     """With a file it is downloaded and cached in a temporary file"""
     # TODO: Mock this
     downloaded = tools.cache_it(
         'http://www.sat.gob.mx/sitio_internet/cfd/3/cadenaoriginal_3_2/cadenaoriginal_3_2.xslt')  # noqa
     content_xslt = downloaded
     content_xml = self.real_document_xml
     converted = tools.get_original(content_xml, content_xslt)
     self.assertTrue(
         converted,
         'I read the content of a cached file and the result '
         'was not correct.')
Exemplo n.º 7
0
 def test_007_cache(self):
     """With a file it is downloaded and cached in a temporary file"""
     # TODO: Mock this
     downloaded = tools.cache_it(self.cadena_travis)
     content_xslt = downloaded
     content_xml = self.real_document_xml
     converted = tools.get_original(content_xml, content_xslt)
     self.assertTrue(
         converted,
         'I read the content of a cached file and the result '
         'was not correct.')
     self.assertTrue(len(tools.cached) > 1,
                     'Cache dictionary was not cached properly')