def test_scripts_minified(self): media = wsgi.Scripts('/media/', minified=True) self.assertEqual(media.absolute_path('bla/foo'), '/media/bla/foo.min.js') self.assertEqual(media.absolute_path('bla/foo.min.js'), '/media/bla/foo.min.js') self.assertEqual(media.absolute_path('bla/foo.js'), '/media/bla/foo.js')
def test_media_path(self): media = wsgi.Scripts( '/media/', known_libraries={'jquery': 'http://bla.foo/jquery'}) self.assertTrue(media.is_relative('bla/test.js')) path = media.absolute_path('bla/foo.js') self.assertEqual(path, '/media/bla/foo.js') self.assertEqual(media.absolute_path('/bla/foo.js'), '/bla/foo.js') self.assertEqual(media.absolute_path('jquery'), 'http://bla.foo/jquery.js')
def test_script(self): links = wsgi.Scripts('/static/') self.assertTrue(links.known_libraries) links.append('require') self.assertTrue(links._requirejs) html = links.render() lines = html.split('\n') self.assertEqual(len(lines), 6) require = links.known_libraries.get('require') self.assertEqual( lines[4], "<script src='%s.js' type='application/javascript'></script>" % require) self.assertEqual(lines[5], '')
def test_media_path(self): media = wsgi.Scripts('/media/') self.assertTrue(media.is_relative('bla/test.js')) path = media.absolute_path('bla/foo.js') self.assertEqual(path, '/media/bla/foo.js') self.assertEqual(media.absolute_path('/bla/foo.js'), '/bla/foo.js')
def test_script(self): links = wsgi.Scripts('/static/') links.require.append('require') html = links.render() lines = html.split('\n') self.assertEqual(len(lines), 4)