This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r26524 | srichter | 2004-07-14 03:45:38 -0400 (Wed, 14 Jul 2004) | 6 lines r26551 | srichter | 2004-07-15 03:06:37 -0400 (Thu, 15 Jul 2004) | 6 lines r26522 | pruggera | 2004-07-14 01:42:06 -0400 (Wed, 14 Jul 2004) | 1 line r26531 | pruggera | 2004-07-14 13:00:15 -0400 (Wed, 14 Jul 2004) | 1 line r26534 | pruggera | 2004-07-14 15:55:34 -0400 (Wed, 14 Jul 2004) | 1 line r26540 | pruggera | 2004-07-14 18:14:25 -0400 (Wed, 14 Jul 2004) | 1 line
- Loading branch information
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2001, 2002 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE. | ||
# | ||
############################################################################## | ||
"""Unit tests for Dependable class. | ||
$Id$ | ||
""" | ||
from unittest import TestCase, TestSuite, main, makeSuite | ||
from zope.app.annotation.attribute import AttributeAnnotations | ||
from zope.app.tests.placelesssetup import PlacelessSetup | ||
|
||
class C(object): | ||
pass | ||
|
||
class Test(PlacelessSetup, TestCase): | ||
|
||
def factory(self): | ||
from zope.app.dependable import Dependable | ||
return Dependable(AttributeAnnotations(C())) | ||
|
||
def testVerifyInterface(self): | ||
from zope.interface.verify import verifyObject | ||
from zope.app.dependable.interfaces import IDependable | ||
object = self.factory() | ||
verifyObject(IDependable, object) | ||
|
||
def testBasic(self): | ||
dependable = self.factory() | ||
self.failIf(dependable.dependents()) | ||
dependable.addDependent('/a/b') | ||
dependable.addDependent('/c/d') | ||
dependable.addDependent('/c/e') | ||
dependable.addDependent('/c/d') | ||
dependents = list(dependable.dependents()) | ||
dependents.sort() | ||
self.assertEqual(dependents, ['/a/b', '/c/d', '/c/e']) | ||
dependable.removeDependent('/c/d') | ||
dependents = list(dependable.dependents()) | ||
dependents.sort() | ||
self.assertEqual(dependents, ['/a/b', '/c/e']) | ||
dependable.removeDependent('/c/d') | ||
dependents = list(dependable.dependents()) | ||
dependents.sort() | ||
self.assertEqual(dependents, ['/a/b', '/c/e']) | ||
|
||
def testRelativeAbsolute(self): | ||
obj = self.factory() | ||
# Hack the object to have a parent path | ||
obj.pp = "/a/" | ||
obj.pplen = len(obj.pp) | ||
obj.addDependent("foo") | ||
self.assertEqual(obj.dependents(), ("/a/foo",)) | ||
obj.removeDependent("/a/foo") | ||
self.assertEqual(obj.dependents(), ()) | ||
obj.addDependent("/a/bar") | ||
self.assertEqual(obj.dependents(), ("/a/bar",)) | ||
obj.removeDependent("bar") | ||
self.assertEqual(obj.dependents(), ()) | ||
|
||
def test_suite(): | ||
return TestSuite(( | ||
makeSuite(Test), | ||
)) | ||
|
||
if __name__=='__main__': | ||
main(defaultTest='test_suite') |