summaryrefslogtreecommitdiffstats
path: root/tests/unit/test-011-wallace_resources.py
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-03-19 19:46:34 -0400
committerThomas Bruederli <bruederli@kolabsys.com>2014-03-19 19:46:34 -0400
commit3d3b77f78c11151e174184335dfc1c6bd05bfa29 (patch)
treef9b6cbd6f3543d39eb6ef0d64353be640af1fc12 /tests/unit/test-011-wallace_resources.py
parent53e46b7870e48d0a76a997737d4c7df53dee3bd8 (diff)
downloadpykolab-3d3b77f78c11151e174184335dfc1c6bd05bfa29.tar.gz
Get resource owner information from parent collection if not set directly
Diffstat (limited to 'tests/unit/test-011-wallace_resources.py')
-rw-r--r--tests/unit/test-011-wallace_resources.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/unit/test-011-wallace_resources.py b/tests/unit/test-011-wallace_resources.py
index 8b01874..62bfd27 100644
--- a/tests/unit/test-011-wallace_resources.py
+++ b/tests/unit/test-011-wallace_resources.py
@@ -247,6 +247,7 @@ class TestWallaceResources(unittest.TestCase):
self.patch(pykolab.auth.Auth, "disconnect", self._mock_nop)
self.patch(pykolab.auth.Auth, "find_resource", self._mock_find_resource)
self.patch(pykolab.auth.Auth, "get_entry_attributes", self._mock_get_entry_attributes)
+ self.patch(pykolab.auth.Auth, "search_entry_by_attribute", self._mock_search_entry_by_attribute)
# intercept calls to smtplib.SMTP.sendmail()
import smtplib
@@ -268,6 +269,12 @@ class TestWallaceResources(unittest.TestCase):
(_, uid) = entry.split(',')[0].split('=')
return { 'cn': uid, 'mail': uid + "@example.org", '_attrib': attributes }
+ def _mock_search_entry_by_attribute(self, attr, value, **kw):
+ results = []
+ if value == "cn=Room 101,ou=Resources,dc=example,dc=org":
+ results.append({ 'dn': 'cn=Rooms,ou=Resources,dc=example,dc=org', attr: value, 'owner': 'uid=doe,ou=People,dc=example,dc=org' })
+ return results
+
def _mock_smtp_init(self, host=None, port=None, local_hostname=None, timeout=0):
pass
@@ -353,6 +360,9 @@ class TestWallaceResources(unittest.TestCase):
owner3 = module_resources.get_resource_owner({ 'dn': "uid=cars,ou=Resources,cd=example,dc=org" })
self.assertEqual(owner3, None)
+ owner4 = module_resources.get_resource_owner({ 'dn': "cn=Room 101,ou=Resources,dc=example,dc=org" })
+ self.assertEqual("doe@example.org", owner4['mail'])
+
def test_005_send_response_accept(self):
itip_event = module_resources.itip_events_from_message(message_from_string(itip_non_multipart))