summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 79db94f)
raw | patch | inline | side by side (parent: 79db94f)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 29 Mar 2004 01:36:25 +0000 (01:36 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 29 Mar 2004 01:36:25 +0000 (01:36 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2227 57a73879-2fb5-44c3-a270-3262357dd7e2
test/test_actions.py | patch | blob | history | |
test/test_templating.py | [new file with mode: 0644] | patch | blob |
diff --git a/test/test_actions.py b/test/test_actions.py
index 190fe5daf2e29ff0fc8e3552838879c832aa7f6e..d7a2c91a8976513624907f351c6cfe2c531b62d5 100755 (executable)
--- a/test/test_actions.py
+++ b/test/test_actions.py
class MockNull:\r
def __init__(self, **kwargs):\r
for key, value in kwargs.items():\r
- setattr(self, key, value)\r
+ self.__dict__[key] = value\r
\r
def __call__(self, *args, **kwargs): return MockNull()\r
def __getattr__(self, name):\r
# For example (with just 'client' defined):\r
#\r
# client.db.config.TRACKER_WEB = 'BASE/'\r
- setattr(self, name, MockNull())\r
+ self.__dict__[name] = MockNull()\r
return getattr(self, name)\r
\r
def __getitem__(self, key): return self\r
def __nonzero__(self): return 0\r
def __str__(self): return ''\r
+ def __repr__(self): return '<MockNull 0x%x>'%id(self)\r
\r
def true(*args, **kwargs):\r
return 1\r
if __name__ == '__main__':\r
runner = unittest.TextTestRunner()\r
unittest.main(testRunner=runner)\r
+\r
diff --git a/test/test_templating.py b/test/test_templating.py
--- /dev/null
+++ b/test/test_templating.py
@@ -0,0 +1,244 @@
+import unittest
+from cgi import FieldStorage, MiniFieldStorage
+
+from roundup.cgi.templating import *
+from test_actions import MockNull, true
+
+class MockDatabase(MockNull):
+ def getclass(self, name):
+ return self.classes[name]
+
+class TemplatingTestCase(unittest.TestCase):
+ def setUp(self):
+ self.form = FieldStorage()
+ self.client = MockNull()
+ self.client.db = MockDatabase()
+ self.client.form = self.form
+
+class HTMLDatabaseTestCase(TemplatingTestCase):
+ def test_HTMLDatabase___getitem__(self):
+ db = HTMLDatabase(self.client)
+ self.assert_(isinstance(db['issue'], HTMLClass))
+ self.assert_(isinstance(db['user'], HTMLUserClass))
+ self.assert_(isinstance(db['issue1'], HTMLItem))
+ self.assert_(isinstance(db['user1'], HTMLUser))
+
+ def test_HTMLDatabase___getattr__(self):
+ db = HTMLDatabase(self.client)
+ self.assert_(isinstance(db.issue, HTMLClass))
+ self.assert_(isinstance(db.user, HTMLUserClass))
+ self.assert_(isinstance(db.issue1, HTMLItem))
+ self.assert_(isinstance(db.user1, HTMLUser))
+
+ def test_HTMLDatabase_classes(self):
+ db = HTMLDatabase(self.client)
+ db._db.classes = {'issue':MockNull(), 'user': MockNull()}
+ db.classes()
+
+class FunctionsTestCase(TemplatingTestCase):
+ def test_lookupIds(self):
+ db = HTMLDatabase(self.client)
+ def lookup(key):
+ if key == 'ok':
+ return '1'
+ if key == 'fail':
+ raise KeyError, 'fail'
+ db._db.classes = {'issue': MockNull(lookup=lookup)}
+ prop = MockNull(classname='issue')
+ self.assertEqual(lookupIds(db._db, prop, ['1','2']), ['1','2'])
+ self.assertEqual(lookupIds(db._db, prop, ['ok','2']), ['1','2'])
+ self.assertEqual(lookupIds(db._db, prop, ['ok', 'fail'], 1),
+ ['1', 'fail'])
+ self.assertEqual(lookupIds(db._db, prop, ['ok', 'fail']), ['1'])
+
+ def test_lookupKeys(self):
+ db = HTMLDatabase(self.client)
+ def get(entry, key):
+ return {'1': 'green', '2': 'eggs'}.get(entry, entry)
+ shrubbery = MockNull(get=get)
+ db._db.classes = {'shrubbery': shrubbery}
+ self.assertEqual(lookupKeys(shrubbery, 'spam', ['1','2']),
+ ['green', 'eggs'])
+ self.assertEqual(lookupKeys(shrubbery, 'spam', ['ok','2']), ['ok',
+ 'eggs'])
+
+'''
+class HTMLPermissions:
+ def is_edit_ok(self):
+ def is_view_ok(self):
+ def is_only_view_ok(self):
+ def view_check(self):
+ def edit_check(self):
+
+def input_html4(**attrs):
+def input_xhtml(**attrs):
+
+class HTMLInputMixin:
+ def __init__(self):
+
+class HTMLClass(HTMLInputMixin, HTMLPermissions):
+ def __init__(self, client, classname, anonymous=0):
+ def __repr__(self):
+ def __getitem__(self, item):
+ def __getattr__(self, attr):
+ def designator(self):
+ def getItem(self, itemid, num_re=re.compile('-?\d+')):
+ def properties(self, sort=1):
+ def list(self, sort_on=None):
+ def csv(self):
+ def propnames(self):
+ def filter(self, request=None, filterspec={}, sort=(None,None),
+ def classhelp(self, properties=None, label='(list)', width='500',
+ def submit(self, label="Submit New Entry"):
+ def history(self):
+ def renderWith(self, name, **kwargs):
+
+class HTMLItem(HTMLInputMixin, HTMLPermissions):
+ def __init__(self, client, classname, nodeid, anonymous=0):
+ def __repr__(self):
+ def __getitem__(self, item):
+ def __getattr__(self, attr):
+ def designator(self):
+ def is_retired(self):
+ def submit(self, label="Submit Changes"):
+ def journal(self, direction='descending'):
+ def history(self, direction='descending', dre=re.compile('\d+')):
+ def renderQueryForm(self):
+
+class HTMLUserPermission:
+ def is_edit_ok(self):
+ def is_view_ok(self):
+ def _user_perm_check(self, type):
+
+class HTMLUserClass(HTMLUserPermission, HTMLClass):
+
+class HTMLUser(HTMLUserPermission, HTMLItem):
+ def __init__(self, client, classname, nodeid, anonymous=0):
+ def hasPermission(self, permission, classname=_marker):
+
+class HTMLProperty(HTMLInputMixin, HTMLPermissions):
+ def __init__(self, client, classname, nodeid, prop, name, value,
+ def __repr__(self):
+ def __str__(self):
+ def __cmp__(self, other):
+ def is_edit_ok(self):
+ def is_view_ok(self):
+
+class StringHTMLProperty(HTMLProperty):
+ def _hyper_repl(self, match):
+ def hyperlinked(self):
+ def plain(self, escape=0, hyperlink=0):
+ def stext(self, escape=0):
+ def field(self, size = 30):
+ def multiline(self, escape=0, rows=5, cols=40):
+ def email(self, escape=1):
+
+class PasswordHTMLProperty(HTMLProperty):
+ def plain(self):
+ def field(self, size = 30):
+ def confirm(self, size = 30):
+
+class NumberHTMLProperty(HTMLProperty):
+ def plain(self):
+ def field(self, size = 30):
+ def __int__(self):
+ def __float__(self):
+
+class BooleanHTMLProperty(HTMLProperty):
+ def plain(self):
+ def field(self):
+
+class DateHTMLProperty(HTMLProperty):
+ def plain(self):
+ def now(self):
+ def field(self, size = 30):
+ def reldate(self, pretty=1):
+ def pretty(self, format=_marker):
+ def local(self, offset):
+
+class IntervalHTMLProperty(HTMLProperty):
+ def plain(self):
+ def pretty(self):
+ def field(self, size = 30):
+
+class LinkHTMLProperty(HTMLProperty):
+ def __init__(self, *args, **kw):
+ def __getattr__(self, attr):
+ def plain(self, escape=0):
+ def field(self, showid=0, size=None):
+ def menu(self, size=None, height=None, showid=0, additional=[],
+
+class MultilinkHTMLProperty(HTMLProperty):
+ def __init__(self, *args, **kwargs):
+ def __len__(self):
+ def __getattr__(self, attr):
+ def __getitem__(self, num):
+ def __contains__(self, value):
+ def reverse(self):
+ def plain(self, escape=0):
+ def field(self, size=30, showid=0):
+ def menu(self, size=None, height=None, showid=0, additional=[],
+
+def make_sort_function(db, classname, sort_on=None):
+ def sortfunc(a, b):
+
+def find_sort_key(linkcl):
+
+def handleListCGIValue(value):
+
+class ShowDict:
+ def __init__(self, columns):
+ def __getitem__(self, name):
+
+class HTMLRequest(HTMLInputMixin):
+ def __init__(self, client):
+ def _post_init(self):
+ def updateFromURL(self, url):
+ def update(self, kwargs):
+ def description(self):
+ def __str__(self):
+ def indexargs_form(self, columns=1, sort=1, group=1, filter=1,
+ def indexargs_url(self, url, args):
+ def base_javascript(self):
+ def batch(self):
+
+class Batch(ZTUtils.Batch):
+ def __init__(self, client, sequence, size, start, end=0, orphan=0,
+ def __getitem__(self, index):
+ def propchanged(self, property):
+ def previous(self):
+ def next(self):
+
+class TemplatingUtils:
+ def __init__(self, client):
+ def Batch(self, sequence, size, start, end=0, orphan=0, overlap=0):
+
+class NoTemplate(Exception):
+class Unauthorised(Exception):
+ def __init__(self, action, klass):
+ def __str__(self):
+def find_template(dir, name, extension):
+
+class Templates:
+ def __init__(self, dir):
+ def precompileTemplates(self):
+ def get(self, name, extension=None):
+ def __getitem__(self, name):
+
+class RoundupPageTemplate(PageTemplate.PageTemplate):
+ def getContext(self, client, classname, request):
+ def render(self, client, classname, request, **options):
+ def __repr__(self):
+'''
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(HTMLDatabaseTestCase))
+ suite.addTest(unittest.makeSuite(FunctionsTestCase))
+ return suite
+
+if __name__ == '__main__':
+ runner = unittest.TextTestRunner()
+ unittest.main(testRunner=runner)
+