Commit 9b10d367 authored by sylvain.thenault@logilab.fr's avatar sylvain.thenault@logilab.fr
Browse files

fix tests

--HG--
branch : tls-sprint
parent 12e46a39f3f2
# pylint: disable-msg=W0622
"""cubicweb-file packaging information"""
distname = "cubicweb-file"
modname = distname.split('-', 1)[1]
numversion = (1, 4, 3)
version = '.'.join(str(num) for num in numversion)
license = 'LGPL'
copyright = '''Copyright (c) 2003-2009 LOGILAB S.A. (Paris, FRANCE).
http://www.logilab.fr/ -- mailto:contact@logilab.fr'''
author = "Logilab"
author_email = "contact@logilab.fr"
web = ''
short_desc = "Raw file support for the CubicWeb framework"
long_desc = """CubicWeb is a entities / relations bases knowledge management system
developped at Logilab.
.
This package provides schema and views to store files and images in cubicweb
applications.
.
"""
from os import listdir
from os.path import join
CUBES_DIR = join('share', 'cubicweb', 'cubes')
try:
data_files = [
[join(CUBES_DIR, 'file'),
[fname for fname in listdir('.')
if fname.endswith('.py') and fname != 'setup.py']],
[join(CUBES_DIR, 'file', 'data'),
[join('data', fname) for fname in listdir('data')]],
[join(CUBES_DIR, 'file', 'wdoc'),
[join('wdoc', fname) for fname in listdir('wdoc')]],
[join(CUBES_DIR, 'file', 'views'),
[join('views', fname) for fname in listdir('views') if fname.endswith('.py')]],
[join(CUBES_DIR, 'file', 'i18n'),
[join('i18n', fname) for fname in listdir('i18n')]],
[join(CUBES_DIR, 'file', 'migration'),
[join('migration', fname) for fname in listdir('migration')]],
]
except OSError:
# we are in an installed directory
pass
cube_eid = 20320
# used packages
__use__ = ()
......@@ -11,7 +11,7 @@ from cubicweb.devtools import ApptestConfiguration
def unabsolutize(path):
parts = path.split(os.sep)
for i, part in reversed(tuple(enumerate(parts))):
if part in ('cubicweb', 'cubes', 'cubes'):
if part.startswith('cubicweb') or part == 'cubes':
return '/'.join(parts[i+1:])
raise Exception('duh? %s' % path)
......@@ -20,6 +20,9 @@ class CubicWebConfigurationTC(TestCase):
self.config = ApptestConfiguration('data')
self.config._cubes = ('email', 'file')
def tearDown(self):
os.environ.pop('CW_CUBES_PATH', None)
def test_reorder_cubes(self):
# jpl depends on email and file and comment
# email depends on file
......
......@@ -183,28 +183,25 @@ class EntityTC(EnvBasedTC):
def test_entity_unrelated(self):
p = self.add_entity('Personne', nom=u'di mascio', prenom=u'adrien')
e = self.add_entity('Tag', name=u'x')
rschema = e.e_schema.subject_relation('tags')
related = [r.eid for r in e.tags]
self.failUnlessEqual(related, [])
unrelated = [reid for rview, reid in e.vocabulary(rschema, 'subject')]
unrelated = [r[0] for r in e.unrelated('tags', 'Personne', 'subject')]
self.failUnless(p.eid in unrelated)
self.execute('SET X tags Y WHERE X is Tag, Y is Personne')
e = self.entity('Any X WHERE X is Tag')
unrelated = [reid for rview, reid in e.vocabulary(rschema, 'subject')]
unrelated = [r[0] for r in e.unrelated('tags', 'Personne', 'subject')]
self.failIf(p.eid in unrelated)
def test_entity_unrelated_limit(self):
e = self.add_entity('Tag', name=u'x')
self.add_entity('Personne', nom=u'di mascio', prenom=u'adrien')
self.add_entity('Personne', nom=u'di mascio', prenom=u'gwen')
rschema = e.e_schema.subject_relation('tags')
self.assertEquals(len(e.unrelated(rschema, 'Personne', 'subject', limit=1)),
self.assertEquals(len(e.unrelated('tags', 'Personne', 'subject', limit=1)),
1)
def test_new_entity_unrelated(self):
e = self.etype_instance('EUser')
rschema = e.e_schema.subject_relation('in_group')
unrelated = [reid for rview, reid in e.vocabulary(rschema, 'subject')]
unrelated = [r[0] for r in e.unrelated('in_group', 'EGroup', 'subject')]
# should be default groups but owners, i.e. managers, users, guests
self.assertEquals(len(unrelated), 3)
......
......@@ -12,6 +12,8 @@ from cubicweb.interfaces import IMileStone
class YesSchema:
def __contains__(self, something):
return True
WEBVIEWSDIR = join(BASE, 'web', 'views')
class VRegistryTC(TestCase):
......@@ -20,10 +22,11 @@ class VRegistryTC(TestCase):
self.vreg = CubicWebRegistry(config)
config.bootstrap_cubes()
self.vreg.schema = config.load_schema()
def test_load(self):
self.vreg.load_file(join(BASE, 'web', 'views'), 'euser.py')
self.vreg.load_file(join(BASE, 'web', 'views'), 'baseviews.py')
self.vreg.init_registration([WEBVIEWSDIR])
self.vreg.load_file(join(WEBVIEWSDIR, 'euser.py'), 'cubicweb.web.views.euser')
self.vreg.load_file(join(WEBVIEWSDIR, 'baseviews.py'), 'cubicweb.web.views.baseviews')
fpvc = [v for v in self.vreg.registry_objects('views', 'primary')
if v.__module__ == 'cubicweb.web.views.euser'][0]
fpv = fpvc(None, None)
......@@ -31,8 +34,9 @@ class VRegistryTC(TestCase):
self.assertRaises(AttributeError, fpv.render_entity_attributes, None, None)
def test_load_interface_based_vojects(self):
self.vreg.load_file(join(BASE, 'web', 'views'), 'idownloadable.py')
self.vreg.load_file(join(BASE, 'web', 'views'), 'baseviews.py')
self.vreg.init_registration([WEBVIEWSDIR])
self.vreg.load_file(join(WEBVIEWSDIR, 'idownloadable.py'), 'cubicweb.web.views.idownloadable')
self.vreg.load_file(join(WEBVIEWSDIR, 'baseviews.py'), 'cubicweb.web.views.baseviews')
# check loading baseviews after idownloadable isn't kicking interface based views
self.assertEquals(len(self.vreg['views']['primary']), 2)
......@@ -57,6 +61,7 @@ class VRegistryTC(TestCase):
class MyCard(Card):
__implements__ = (IMileStone,)
self.vreg.reset()
self.vreg._loadedmods[__name__] = {}
self.vreg.register_vobject_class(MyCard)
self.vreg.register_objects([join(BASE, 'web', 'views', 'iprogress.py')])
# check progressbar isn't kicked
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment