[Checkins] SVN: hurry.explorertests/ Initial ipmort.

Martijn Faassen faassen at infrae.com
Thu Dec 4 03:23:28 EST 2008


Log message for revision 93603:
  Initial ipmort.
  

Changed:
  A   hurry.explorertests/
  A   hurry.explorertests/trunk/
  A   hurry.explorertests/trunk/buildout.cfg
  A   hurry.explorertests/trunk/setup.py
  A   hurry.explorertests/trunk/src/
  A   hurry.explorertests/trunk/src/hurry/
  A   hurry.explorertests/trunk/src/hurry/__init__.py
  A   hurry.explorertests/trunk/src/hurry/explorertests/
  A   hurry.explorertests/trunk/src/hurry/explorertests/__init__.py
  A   hurry.explorertests/trunk/src/hurry/explorertests/configure.zcml
  A   hurry.explorertests/trunk/src/hurry/explorertests/jstests.py
  A   hurry.explorertests/trunk/src/hurry/explorertests/jstests_templates/
  A   hurry.explorertests/trunk/src/hurry/explorertests/jstests_templates/index.pt
  A   hurry.explorertests/trunk/src/hurry/explorertests/jstests_templates/tabinfo.pt
  A   hurry.explorertests/trunk/src/hurry/explorertests/resources/
  A   hurry.explorertests/trunk/src/hurry/explorertests/resources/testexplorer.js
  A   hurry.explorertests/trunk/src/hurry/explorertests/static/
  A   hurry.explorertests/trunk/src/hurry/explorertests/static/history_asset.gif

-=-
Added: hurry.explorertests/trunk/buildout.cfg
===================================================================
--- hurry.explorertests/trunk/buildout.cfg	                        (rev 0)
+++ hurry.explorertests/trunk/buildout.cfg	2008-12-04 08:23:27 UTC (rev 93603)
@@ -0,0 +1,61 @@
+[buildout]
+develop = . hurry.explorer
+parts = eggbasket app data zopectl test
+newest = false
+extends = http://grok.zope.org/releaseinfo/grok-0.14.cfg
+versions = versions
+
+[app]
+recipe = zc.zope3recipes>=0.5.3:application
+eggs = hurry.explorertests
+site.zcml = <include package="hurry.explorertests" />
+            <include package="zope.app.twisted" />
+
+            <configure i18n_domain="hurry.explorertests">
+              <unauthenticatedPrincipal id="zope.anybody"
+                                        title="Unauthenticated User" />
+              <unauthenticatedGroup id="zope.Anybody"
+                                    title="Unauthenticated Users" />
+              <authenticatedGroup id="zope.Authenticated"
+                                title="Authenticated Users" />
+              <everybodyGroup id="zope.Everybody"
+                              title="All Users" />
+              <principal id="zope.manager"
+                         title="Manager"
+                         login="admin"
+                         password_manager="Plain Text"
+                         password="admin"
+                         />
+
+              <!-- Replace the following directive if you do not want
+                   public access -->
+              <grant permission="zope.View"
+                     principal="zope.Anybody" />
+              <grant permission="zope.app.dublincore.view"
+                     principal="zope.Anybody" />
+
+              <role id="zope.Manager" title="Site Manager" />
+              <role id="zope.Member" title="Site Member" />
+              <grantAll role="zope.Manager" />
+              <grant role="zope.Manager"
+                     principal="zope.manager" />
+           </configure>
+
+[data]
+recipe = zc.recipe.filestorage
+
+# this section named so that the start/stop script is called bin/zopectl
+[zopectl]
+recipe = zc.zope3recipes:instance
+application = app
+zope.conf = ${data:zconfig}
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = hurry.explorertests
+defaults = ['--tests-pattern', '^f?tests$', '-v']
+
+[eggbasket]
+recipe = z3c.recipe.eggbasket
+eggs = grok
+url = http://grok.zope.org/releaseinfo/grok-eggs-0.14.tgz

Added: hurry.explorertests/trunk/setup.py
===================================================================
--- hurry.explorertests/trunk/setup.py	                        (rev 0)
+++ hurry.explorertests/trunk/setup.py	2008-12-04 08:23:27 UTC (rev 93603)
@@ -0,0 +1,44 @@
+from setuptools import setup, find_packages
+
+import sys, os
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+long_description = ''
+#(
+#    read('README.txt')
+#    + '\n' +
+#    read('CHANGES.txt')
+#    + '\n' +
+#    'Download\n'
+#    '********\n'
+#    )
+
+
+setup(
+    name='hurry.explorertests',
+    version='0.1dev',
+    description="Javascript based tests for hurry.explorer. Uses grok for JSON",
+    long_description = long_description,
+    classifiers=[],
+    keywords='',
+    author='Martijn Faassen',
+    author_email='faassen at startifact.com',
+    license='ZPL 2.1',
+    packages=find_packages('src'),
+    namespace_packages=['hurry'],
+    package_dir={'': 'src'},
+    include_package_data=True,
+    zip_safe=False,
+    install_requires=[
+        'setuptools',
+        'grok',
+        'z3c.objpath',
+        'grokui.admin',
+        'hurry.zoperesource',
+        'hurry.yui >= 2.6.0.3',
+        'hurry.zopeyui',
+        'hurry.explorer',
+        ],
+    )

Added: hurry.explorertests/trunk/src/hurry/__init__.py
===================================================================
--- hurry.explorertests/trunk/src/hurry/__init__.py	                        (rev 0)
+++ hurry.explorertests/trunk/src/hurry/__init__.py	2008-12-04 08:23:27 UTC (rev 93603)
@@ -0,0 +1,7 @@
+# this is a namespace package
+try:
+    import pkg_resources
+    pkg_resources.declare_namespace(__name__)
+except ImportError:
+    import pkgutil
+    __path__ = pkgutil.extend_path(__path__, __name__)

Added: hurry.explorertests/trunk/src/hurry/explorertests/__init__.py
===================================================================
--- hurry.explorertests/trunk/src/hurry/explorertests/__init__.py	                        (rev 0)
+++ hurry.explorertests/trunk/src/hurry/explorertests/__init__.py	2008-12-04 08:23:27 UTC (rev 93603)
@@ -0,0 +1 @@
+# this is a package

Added: hurry.explorertests/trunk/src/hurry/explorertests/configure.zcml
===================================================================
--- hurry.explorertests/trunk/src/hurry/explorertests/configure.zcml	                        (rev 0)
+++ hurry.explorertests/trunk/src/hurry/explorertests/configure.zcml	2008-12-04 08:23:27 UTC (rev 93603)
@@ -0,0 +1,17 @@
+<configure
+  xmlns="http://namespaces.zope.org/zope"
+  xmlns:grok="http://namespaces.zope.org/grok"
+  xmlns:browser="http://namespaces.zope.org/browser">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="grok" />
+
+  <includeDependencies package="." />
+ 
+  <grok:grok package="."/>
+ 
+  <browser:resourceDirectory
+      name="explorertests"
+      directory="resources" />
+
+</configure>

Added: hurry.explorertests/trunk/src/hurry/explorertests/jstests.py
===================================================================
--- hurry.explorertests/trunk/src/hurry/explorertests/jstests.py	                        (rev 0)
+++ hurry.explorertests/trunk/src/hurry/explorertests/jstests.py	2008-12-04 08:23:27 UTC (rev 93603)
@@ -0,0 +1,79 @@
+import grok
+from z3c.objpath.path import resolve, path
+
+from hurry import resource
+from hurry import yui
+from hurry.explorer import explorer
+
+explorertests_lib = resource.Library('explorertests')
+
+explorertests = resource.ResourceInclusion(
+    explorertests_lib,
+    'testexplorer.js',
+    depends=[explorer, yui.logger, yui.yuitest],
+    bottom=True,
+    )
+
+class TestContainer(grok.Container):
+    pass
+
+class JsTestApp(TestContainer, grok.Application):
+    pass
+
+ at grok.subscribe(JsTestApp, grok.IObjectAddedEvent)
+def add(obj, event):
+    obj['a'] = TestContainer()
+    obj['b'] = TestContainer()
+    obj['a']['c'] = TestContainer()
+    obj['a']['d'] = TestContainer()
+    obj['b']['e'] = TestContainer()
+    obj['b']['f'] = TestContainer()
+    obj['a']['c']['g'] = TestContainer()
+    obj['a']['c']['h'] = TestContainer()
+    
+class ExplorerInfo(grok.JSON):
+    grok.context(TestContainer)
+
+    def treeinfo(self):
+        container = self._container()
+        nodes = []
+        for obj in container.values():
+            if not isinstance(obj, TestContainer):
+                continue
+            nodes.append(
+                {'label': obj.__name__,
+                 'path': path(grok.getSite(), obj)})
+        return { 'nodes': nodes }
+        
+    def tableinfo(self):
+        container = self._container()
+        result = []
+        for key, value in container.items():
+            title = key
+            container = isinstance(value, TestContainer)
+            result.append({'name': key,
+                           'title': title,
+                           'path': path(grok.getSite(), value),
+                           'container': container})
+        return {'records' : result }
+
+    def _container(self):
+        return resolve(grok.getSite(), self.request.form['nodepath'])
+
+class TabInfo(grok.View):
+    grok.context(TestContainer)
+
+    def update(self):
+        self.container = resolve(grok.getSite(), self.request.form['nodepath'])
+    
+class Index(grok.View):
+    grok.context(TestContainer)
+
+    def update(self):
+        resource.bottom()
+        
+        yui.reset.need()
+        yui.fonts.need()
+        yui.grids.need()
+        yui.sam.need()
+        explorertests.need()

Added: hurry.explorertests/trunk/src/hurry/explorertests/jstests_templates/index.pt
===================================================================
--- hurry.explorertests/trunk/src/hurry/explorertests/jstests_templates/index.pt	                        (rev 0)
+++ hurry.explorertests/trunk/src/hurry/explorertests/jstests_templates/index.pt	2008-12-04 08:23:27 UTC (rev 93603)
@@ -0,0 +1,45 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Explorer tests</title>
+<link rel="stylesheet" type="text/css" href="http://developer.yahoo.com/yui/examples/treeview/assets/css/folders/tree.css" />
+
+<style type="text/css">
+#yui-history-iframe {
+  position:absolute;
+  top:0; left:0;
+  width:1px; height:1px;
+  visibility:hidden;
+}
+</style>
+</head>
+
+<body class="yui-skin-sam">
+<!-- required by UI browser history manager IE support -->
+<iframe id="yui-history-iframe" tal:attributes="src static/history_asset.gif"></iframe>
+<input id="yui-history-field" type="hidden" />
+
+<h1>Explorer tests</h1>
+
+<div id="rootpath" rootpath="/" />
+
+<div id="doc" class="yui-t1">
+
+  <div id="hd">
+    <strong>Location:</strong> <span id="location"></span>
+  </div>
+  <div id="bd">
+    <div id="yui-main">
+      <div class="yui-b">
+        <div id="main" class="yui-navset"></div>
+      </div>
+    </div>
+    <div class="yui-b">
+      <div id="tree"></div>
+    </div>
+  </div>
+  <div id="ft"></div>
+</div>
+
+</body>
+</html>

Added: hurry.explorertests/trunk/src/hurry/explorertests/jstests_templates/tabinfo.pt
===================================================================
--- hurry.explorertests/trunk/src/hurry/explorertests/jstests_templates/tabinfo.pt	                        (rev 0)
+++ hurry.explorertests/trunk/src/hurry/explorertests/jstests_templates/tabinfo.pt	2008-12-04 08:23:27 UTC (rev 93603)
@@ -0,0 +1,4 @@
+<p>This is object <span tal:replace="view/container/__name__"></span></p>
+<div id="datatable"></div>
+<div id="buttons"></div>
+

Added: hurry.explorertests/trunk/src/hurry/explorertests/resources/testexplorer.js
===================================================================
--- hurry.explorertests/trunk/src/hurry/explorertests/resources/testexplorer.js	                        (rev 0)
+++ hurry.explorertests/trunk/src/hurry/explorertests/resources/testexplorer.js	2008-12-04 08:23:27 UTC (rev 93603)
@@ -0,0 +1,86 @@
+(function() {
+var explorerTestCase = new YAHOO.tool.TestCase({
+    name: "Explorer testcase",
+
+    // expand the top node and see whether we get the expected
+    // content
+    testExpand: function() {
+        var tree = PLOR.explorer.getTree();
+        var Assert = YAHOO.util.Assert;
+        var subscribeHandler = function() {
+            tree.unsubscribe("expandComplete", subscribeHandler);
+            this.resume(function() {
+                var top = tree.getRoot().children[0];
+                Assert.areEqual("a", top.children[0].data.label);
+                Assert.areEqual("b", top.children[1].data.label);
+            });
+        }
+        tree.subscribe("expandComplete", subscribeHandler, this, true);
+        tree.collapseAll();
+        tree.getRoot().children[0].expand();
+        this.wait();
+    },
+
+    // expand the 'a' node and see whether we get the expected
+    // content
+    testExpand2: function() {
+        var tree = PLOR.explorer.getTree();
+        var Assert = YAHOO.util.Assert;
+        // when we expand top node
+        var top = tree.getRoot().children[0];
+        var subscribeHandler = function() {
+            tree.unsubscribe("expandComplete", subscribeHandler);
+            // when we expand the 'a' node
+            var a = top.children[0];
+            var innerSubscribeHandler = function() {
+                tree.unsubscribe("expandComplete", innerSubscribeHandler);
+                this.resume(function() {
+                    Assert.areEqual("c", a.children[0].data.label);
+                    Assert.areEqual("d", a.children[1].data.label);
+                });
+            };
+            tree.subscribe("expandComplete", innerSubscribeHandler, 
+                           this, true);
+            a.expand();
+        };
+
+        tree.subscribe("expandComplete", subscribeHandler, this, true);
+        tree.collapseAll();
+        top.expand();
+        this.wait();
+    },
+
+    // click on the 'a' node and see whether the contents is correct
+    testClick: function() {
+        var Assert = YAHOO.util.Assert;
+        var tree = PLOR.explorer.getTree();
+
+        var top = tree.getRoot().children[0];
+        var sub = function() {
+            tree.unsubscribe("expandComplete", sub);
+            var a = top.children[0];
+            YAHOO.util.UserAction.click(a.getLabelEl());
+        };
+        tree.subscribe("expandComplete", sub, this, true);
+        tree.collapseAll();
+        top.expand();
+        // XXX ugh, have to wait half a second to load data and
+        // hope it is enough...
+        this.wait(function() {
+            var table = PLOR.explorer.getDataTable();
+            Assert.areEqual("c", table.getRecord(0).getData().name);
+            Assert.areEqual("d", table.getRecord(1).getData().name);
+        }, 500);
+    }
+});
+
+var suite = new YAHOO.tool.TestSuite("Explorer testsuite");
+suite.add(explorerTestCase);
+
+YAHOO.util.Event.onDOMReady(function() {
+  var logger = new YAHOO.tool.TestLogger();
+  YAHOO.tool.TestRunner.add(suite);
+  YAHOO.tool.TestRunner.run();
+});
+
+})();

Added: hurry.explorertests/trunk/src/hurry/explorertests/static/history_asset.gif
===================================================================
(Binary files differ)


Property changes on: hurry.explorertests/trunk/src/hurry/explorertests/static/history_asset.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream



More information about the Checkins mailing list