Esempio n. 1
0
 def test_local_copy(self):
     here = os.path.dirname(__file__)
     target_url = 'file://%s' % self._tmpdir
     from van.static.cdn import extract_cmd
     extract_cmd(
             target=target_url,
             resources=['van.static:tests/example'],
             args=['export_cmd'])
     from pkg_resources import get_distribution
     dist = get_distribution('van.static')
     d = self._tmpdir
     self.assertEqual(os.listdir(d), ['van.static'])
     d = os.path.join(d, 'van.static')
     self.assertEqual(os.listdir(d), [dist.version])
     d = os.path.join(d, dist.version)
     self.assertEqual(os.listdir(d), ['tests', 'van.static-%s-ORSXG5DTF5SXQYLNOBWGK===.stamp' % dist.version])
     d = os.path.join(d, 'tests')
     self.assertEqual(os.listdir(d), ['example'])
     d = os.path.join(d, 'example')
     self.assertEqual(sorted(os.listdir(d)), ['css', 'example.txt', 'images', 'js'])
     f = open(os.path.join(d, 'example.txt'), 'r')
     self.assertEqual(
             f.read(),
             'Example Text\n')
     f.close()
     d = os.path.join(d, 'css')
     self.assertEqual(os.listdir(d), ['example.css', 'example_imported.css'])
Esempio n. 2
0
 def test_defaults(self, extract, logging):
     from van.static.cdn import extract_cmd
     extract_cmd(
             resources=['van.static.tests:static'],
             yui_compressor=True,
             target='file:///wherever',
             args=['extract_cmd'])
     extract.assert_called_once_with(
             ['van.static.tests:static'],
             'file:///wherever',
             True,
             ignore_stamps=False)
     extract.reset_mock()
     extract_cmd(
             resources=['van.static.tests:static'],
             yui_compressor=True,
             target='file:///wherever',
             args=[
                 'extract_cmd',
                 '--resource', 'van.static.tests:static',
                 '--target', 'file:///somewhere_else',
                 '--resource', 'van.static.tests:another_static',
                 '--no-yui-compressor',
                 '--ignore-stamps'
                 ])
     extract.assert_called_once_with(
             ['van.static.tests:static', 'van.static.tests:another_static'],
             'file:///somewhere_else',
             False,
             ignore_stamps=True)
Esempio n. 3
0
 def test_args(self, extract, logging):
     from van.static.cdn import extract_cmd
     # all possible arguments
     extract_cmd(
             args=[
                 'export_cmd',
                 '--resource', 'van.static.tests:static',
                 '--target', 's3:///somewhere_else',
                 '--resource', 'van.static.tests:another_static',
                 '--cssutils-minify',
                 '--cssutils-resolve-imports',
                 '--yui-compressor',
                 '--encoding', 'gzip',
                 '--aws-access-key', '1234',
                 '--aws-secret-key', '12345',
                 '--loglevel', 'DEBUG',
                 ])
     extract.assert_called_once_with(
             ['van.static.tests:static', 'van.static.tests:another_static'],
             's3:///somewhere_else',
             True,
             encodings=['gzip'],
             aws_secret_key='12345',
             aws_access_key='1234',
             ignore_stamps=False,
             cssutils_minify=True,
             cssutils_resolve_imports=True)
     logging.basicConfig.assert_called_once_with(level=logging.DEBUG)
     logging.reset_mock()
     extract.reset_mock()
     # minimum arguments
     extract_cmd(
             args=[
                 'extract_cmd',
                 '--resource', 'van.static.tests:static',
                 '--target', 'file:///somewhere_else',
                 ])
     extract.assert_called_once_with(
             ['van.static.tests:static'],
             'file:///somewhere_else',
             False,
             ignore_stamps=False)
     logging.basicConfig.assert_called_once_with(level=logging.WARN)