Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
39695e98ba35
Commit
4c33b368
authored
Feb 18, 2009
by
sylvain.thenault@logilab.fr
Browse files
test and fix interface based objects cleaning
--HG-- branch : tls-sprint
parent
29ba95ea7e7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
cwvreg.py
View file @
39695e98
...
...
@@ -105,7 +105,7 @@ class CubicWebRegistry(VRegistry):
kwargs
[
'clear'
]
=
True
super
(
CubicWebRegistry
,
self
).
register
(
obj
,
**
kwargs
)
# XXX bw compat
ifaces
=
getattr
(
obj
,
'accepts
_interfaces
'
,
None
)
ifaces
=
use
_interfaces
(
obj
)
if
ifaces
:
self
.
_needs_iface
[
obj
]
=
frozenset
(
ifaces
)
...
...
@@ -122,12 +122,15 @@ class CubicWebRegistry(VRegistry):
interfaces
=
set
()
for
classes
in
self
.
get
(
'etypes'
,
{}).
values
():
for
cls
in
classes
:
interfaces
.
update
(
cls
.
__implements__
)
for
iface
in
cls
.
__implements__
:
interfaces
.
update
(
expand_parent_classes
(
iface
))
for
obj
,
ifaces
in
self
.
_needs_iface
.
items
():
if
not
ifaces
&
interfaces
:
self
.
debug
(
'kicking vobject %s (unsupported interface)'
,
obj
)
self
.
unregister
(
obj
)
def
eid_rset
(
self
,
cursor
,
eid
,
etype
=
None
):
"""return a result set for the given eid without doing actual query
(we have the eid, we can suppose it exists and user has access to the
...
...
test/unittest_vregistry.py
View file @
39695e98
...
...
@@ -5,7 +5,9 @@ from os.path import join
from
cubicweb
import
CW_SOFTWARE_ROOT
as
BASE
from
cubicweb.vregistry
import
VObject
from
cubicweb.cwvreg
import
CubicWebRegistry
,
UnknownProperty
from
cubicweb.cwconfig
import
CubicWebConfiguration
from
cubicweb.devtools
import
TestServerConfiguration
from
cubicweb.entities.lib
import
Card
from
cubicweb.interfaces
import
IMileStone
class
YesSchema
:
def
__contains__
(
self
,
something
):
...
...
@@ -14,9 +16,10 @@ class YesSchema:
class
VRegistryTC
(
TestCase
):
def
setUp
(
self
):
config
=
CubicWeb
Configuration
(
'data'
)
config
=
TestServer
Configuration
(
'data'
)
self
.
vreg
=
CubicWebRegistry
(
config
)
self
.
vreg
.
schema
=
YesSchema
()
config
.
bootstrap_cubes
()
self
.
vreg
.
schema
=
config
.
load_schema
()
def
test_load
(
self
):
self
.
vreg
.
load_file
(
join
(
BASE
,
'web'
,
'views'
),
'euser.py'
)
...
...
@@ -45,6 +48,19 @@ class VRegistryTC(TestCase):
self
.
failIf
(
'system.version.cubicweb'
in
self
.
vreg
[
'propertydefs'
])
self
.
failUnless
(
self
.
vreg
.
property_info
(
'system.version.cubicweb'
))
self
.
assertRaises
(
UnknownProperty
,
self
.
vreg
.
property_info
,
'a.non.existent.key'
)
def
test_load_subinterface_based_vobjects
(
self
):
self
.
vreg
.
reset
()
self
.
vreg
.
register_objects
([
join
(
BASE
,
'web'
,
'views'
,
'iprogress.py'
)])
# check progressbar was kicked
self
.
failIf
(
self
.
vreg
[
'views'
].
get
(
'progressbar'
))
class
MyCard
(
Card
):
__implements__
=
(
IMileStone
,)
self
.
vreg
.
reset
()
self
.
vreg
.
register_vobject_class
(
MyCard
)
self
.
vreg
.
register_objects
([
join
(
BASE
,
'web'
,
'views'
,
'iprogress.py'
)])
# check progressbar isn't kicked
self
.
assertEquals
(
len
(
self
.
vreg
[
'views'
][
'progressbar'
]),
1
)
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment