Skip to content

Commit

Permalink
checkpoint some code before I rework it
Browse files Browse the repository at this point in the history
  • Loading branch information
benji-york committed Jul 24, 2006
1 parent 68b86c6 commit aaa5192
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 3 deletions.
62 changes: 62 additions & 0 deletions ftests/real.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta"
i18n_domain="zope"
>

<!-- Turn on the devmode -->
<meta:provides feature="devmode" />

<!-- This file is the equivalent of site.zcml and it is -->
<!-- used for functional testing setup -->

<include package="zope.app" />
<include package="zope.app" file="ftesting.zcml" />

<include files="zopeskel/etc/package-includes/*-meta.zcml" />
<include files="zopeskel/etc/package-includes/*-configure.zcml" />
<include files="zopeskel/etc/package-includes/*-ftesting.zcml" />

<include file="securitypolicy.zcml" />
<include file="securitypolicy-ftesting.zcml" />

<!-- Principals -->

<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 that tests generally run as -->
<principal
id="zope.mgr"
title="Manager"
login="mgr"
password="mgrpw" />

<!-- Bootstrap principal used to make local grant to the principal above -->
<principal
id="zope.globalmgr"
title="Manager"
login="globalmgr"
password="globalmgrpw" />

<grant role="zope.Manager" principal="zope.globalmgr" />

<includeOverrides file="overrides_ftesting.zcml" />

</configure>
38 changes: 35 additions & 3 deletions ftests/reallayer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
from zope.app.server.main import setup, load_options, run
from zope.testbrowser import realproxy
import ThreadedAsync.LoopCallback
import os
import tempfile
import threading
from zope.testbrowser.realproxy import TARGET_PORT

CONF = """\
site-definition %(SITE_ZCML)s
<server http>
type HTTP
address 127.0.0.1:%(TARGET_PORT)s
</server>
<zodb>
<demostorage>
</demostorage>
</zodb>
<accesslog>
</accesslog>
<eventlog>
</eventlog>
"""


class TestbrowserRealClass:

Expand All @@ -19,20 +42,29 @@ def tearDown(self):

def startZope(self, fg=None):
"""start Zope in a daemon thread"""
SITE_ZCML = '/home/benji/workspace/testbrowser3/src/zope/testbrowser/ftests/real.zcml'
TARGET_PORT = realproxy.TARGET_PORT
handle, self.conf_path = tempfile.mkstemp()
os.write(handle, CONF % locals())
os.close(handle)

def go():
# force the server to run on a known port
# force the server to run with a known config
# args = ['-C', self.conf_path]
args = ['-X', 'server/address=%s' % TARGET_PORT,
'-X', 'site-definition=ftesting.zcml']
setup(load_options(args))
run()
run(timeout=1.0)

self.zope_thread = threading.Thread(target=go)
self.zope_thread.setDaemon(True)
self.zope_thread.start()

def stopZope(self):
"""tell Zope to stop and wait for it to do so"""
import time; time.sleep(1)
ThreadedAsync.LoopCallback.exit_status = 0
self.zope_thread.join()
os.remove(self.conf_path)

TestbrowserReal = TestbrowserRealClass()
3 changes: 3 additions & 0 deletions real.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ We can open pages and look at their contents.
>>> browser.contents
u'...</head>...'

>>> browser.contents
u'...[top]...'

>>> browser.getLink('[top]', index=0)
<Link text='[top]' url=u'http://localhost:23123/@@SelectedManagementView.html'>

Expand Down
1 change: 1 addition & 0 deletions utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import re
import sys
import time
from test import pystone

class AmbiguityError(KeyError):
pass
Expand Down

0 comments on commit aaa5192

Please sign in to comment.