--- a/etwist/test/unittest_server.py Mon Jun 27 18:38:08 2011 +0200
+++ b/etwist/test/unittest_server.py Mon Jun 27 18:48:30 2011 +0200
@@ -15,8 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
+
+import os, os.path as osp, glob
+
from cubicweb.devtools.testlib import CubicWebTC
-from cubicweb.etwist.server import host_prefixed_baseurl
+from cubicweb.etwist.server import (host_prefixed_baseurl, ConcatFiles,
+ ConcatFileNotFoundError)
class HostPrefixedBaseURLTC(CubicWebTC):
@@ -50,3 +54,30 @@
self._check('http://localhost:8080/hg/', 'code.cubicweb.org',
'http://localhost:8080/hg/')
+
+class ConcatFilesTC(CubicWebTC):
+
+ def tearDown(self):
+ super(ConcatFilesTC, self).tearDown()
+ self._cleanup_concat_cache()
+ self.config.debugmode = False
+
+ def _cleanup_concat_cache(self):
+ uicachedir = osp.join(self.config.apphome, 'uicache')
+ for fname in glob.glob(osp.join(uicachedir, 'cache_concat_*')):
+ os.unlink(osp.join(uicachedir, fname))
+
+ def test_cache(self):
+ concat = ConcatFiles(self.config, ('cubicweb.ajax.js', 'jquery.js'))
+ self.failUnless(osp.isfile(concat.path))
+
+ def test_404(self):
+ # when not in debug mode, should not crash
+ ConcatFiles(self.config, ('cubicweb.ajax.js', 'dummy.js'))
+ # in debug mode, raise error
+ self.config.debugmode = True
+ try:
+ self.assertRaises(ConcatFileNotFoundError, ConcatFiles, self.config,
+ ('cubicweb.ajax.js', 'dummy.js'))
+ finally:
+ self.config.debugmode = False