当前位置: 首页>>代码示例>>Python>>正文


Python SimpleStoreRequest.locateResource方法代码示例

本文整理汇总了Python中twistedcaldav.test.util.SimpleStoreRequest.locateResource方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleStoreRequest.locateResource方法的具体用法?Python SimpleStoreRequest.locateResource怎么用?Python SimpleStoreRequest.locateResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twistedcaldav.test.util.SimpleStoreRequest的用法示例。


在下文中一共展示了SimpleStoreRequest.locateResource方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_pick_default_other

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
    def test_pick_default_other(self):
        """
        Make calendar
        """

        request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
        inbox = yield request.locateResource("/calendars/users/wsanchez/inbox")

        # default property present
        default = yield inbox.readProperty(caldavxml.ScheduleDefaultCalendarURL, request)
        self.assertEqual(str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/calendar")

        # Create a new default calendar
        newcalendar = yield request.locateResource("/calendars/users/wsanchez/newcalendar")
        yield newcalendar.createCalendarCollection()
        yield inbox.writeProperty(caldavxml.ScheduleDefaultCalendarURL(davxml.HRef("/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/newcalendar")), request)

        # Delete the normal calendar
        calendar = yield request.locateResource("/calendars/users/wsanchez/calendar")
        yield calendar.storeRemove(request)
        yield self.commit()

        request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
        inbox = yield request.locateResource("/calendars/users/wsanchez/inbox")

        default = yield inbox.readProperty(caldavxml.ScheduleDefaultCalendarURL, request)
        self.assertEqual(str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/newcalendar")

        yield self.abort()
开发者ID:eventable,项目名称:CalendarServer,代码行数:31,代码来源:test_resource.py

示例2: test_set_default_vevent_other

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
    def test_set_default_vevent_other(self):
        """
        Test that the default URL can be set to another VEVENT calendar
        """

        request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
        inbox = yield request.locateResource("/calendars/users/wsanchez/inbox")

        # default property is present
        default = yield inbox.readProperty(caldavxml.ScheduleDefaultCalendarURL, request)
        self.assertEqual(str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/calendar")

        # Create a new default calendar
        newcalendar = yield request.locateResource("/calendars/users/wsanchez/newcalendar")
        yield newcalendar.createCalendarCollection()
        yield newcalendar.setSupportedComponents(("VEVENT",))
        yield self.commit()

        request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
        inbox = yield request.locateResource("/calendars/users/wsanchez/inbox")
        yield inbox.writeProperty(caldavxml.ScheduleDefaultCalendarURL(davxml.HRef("/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/newcalendar")), request)

        default = yield inbox.readProperty(caldavxml.ScheduleDefaultCalendarURL, request)
        self.assertEqual(str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/newcalendar")

        yield self.commit()
开发者ID:eventable,项目名称:CalendarServer,代码行数:28,代码来源:test_resource.py

示例3: test_wikiACL

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
    def test_wikiACL(self):
        """
        Ensure shareeAccessControlList( ) honors the access granted by the wiki
        to the sharee, so that delegates of the sharee get the same level of
        access.
        """
        sharedName = yield self.wikiSetup()
        access = WikiAccessLevel.read

        def stubAccessForRecord(*args):
            return succeed(access)

        self.patch(WikiDirectoryRecord, "accessForRecord", stubAccessForRecord)

        request = SimpleStoreRequest(self, "GET", "/calendars/__uids__/user01/")
        collection = yield request.locateResource("/calendars/__uids__/user01/" + sharedName)

        # Simulate the wiki server granting Read access
        acl = (yield collection.shareeAccessControlList(request))
        self.assertFalse("<write/>" in acl.toxml())

        # Simulate the wiki server granting Read-Write access
        access = WikiAccessLevel.write
        acl = (yield collection.shareeAccessControlList(request))
        self.assertTrue("<write/>" in acl.toxml())
开发者ID:nunb,项目名称:calendarserver,代码行数:27,代码来源:test_sharing.py

示例4: test_pick_default_vtodo_calendar

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
    def test_pick_default_vtodo_calendar(self):
        """
        Test that pickNewDefaultCalendar will choose the correct tasks calendar.
        """

        request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
        inbox = yield request.locateResource("/calendars/users/wsanchez/inbox")

        default = yield inbox.readProperty(customxml.ScheduleDefaultTasksURL, request)
        self.assertEqual(str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/tasks")

        yield self.abort()
开发者ID:eventable,项目名称:CalendarServer,代码行数:14,代码来源:test_resource.py

示例5: test_is_default_calendar

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
    def test_is_default_calendar(self):
        """
        Test .isDefaultCalendar() returns the proper class or None.
        """

        # Create a new non-default calendar
        request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
        newcalendar = yield request.locateResource("/calendars/users/wsanchez/newcalendar")
        yield newcalendar.createCalendarCollection()
        yield newcalendar.setSupportedComponents(("VEVENT",))
        inbox = yield request.locateResource("/calendars/users/wsanchez/inbox")
        yield inbox.defaultCalendar(request, "VEVENT")
        yield inbox.defaultCalendar(request, "VTODO")
        yield self.commit()

        request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
        inbox = yield request.locateResource("/calendars/users/wsanchez/inbox")
        calendar = yield request.locateResource("/calendars/users/wsanchez/calendar")
        newcalendar = yield request.locateResource("/calendars/users/wsanchez/newcalendar")
        tasks = yield request.locateResource("/calendars/users/wsanchez/tasks")

        result = yield calendar.isDefaultCalendar(request)
        self.assertTrue(result)

        result = yield newcalendar.isDefaultCalendar(request)
        self.assertFalse(result)

        result = yield tasks.isDefaultCalendar(request)
        self.assertTrue(result)

        yield self.commit()
开发者ID:eventable,项目名称:CalendarServer,代码行数:33,代码来源:test_resource.py

示例6: test_pick_default_vevent_calendar

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
    def test_pick_default_vevent_calendar(self):
        """
        Test that pickNewDefaultCalendar will choose the correct calendar.
        """

        request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
        inbox = yield request.locateResource("/calendars/users/wsanchez/inbox")

        # default property initially present
        prop = yield inbox.readProperty(caldavxml.ScheduleDefaultCalendarURL, request)
        self.assertEqual(str(prop.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/calendar")

        yield self.abort()
开发者ID:eventable,项目名称:CalendarServer,代码行数:15,代码来源:test_resource.py

示例7: test_missing_default_vtodo_calendar

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
    def test_missing_default_vtodo_calendar(self):
        """
        Test that readProperty will not create a missing default calendar.
        """

        request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
        home = yield request.locateResource("/calendars/users/wsanchez/")
        inbox = yield request.locateResource("/calendars/users/wsanchez/inbox")

        # default property present
        default = yield inbox.readProperty(customxml.ScheduleDefaultTasksURL, request)
        self.assertEqual(str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/tasks")

        # Forcibly remove the one we need
        yield home._newStoreHome.removeChildWithName("tasks")
        names = [calendarName for calendarName in (yield home._newStoreHome.listCalendars())]
        self.assertTrue("tasks" not in names)

        # Property is empty now
        default = yield inbox.readProperty(customxml.ScheduleDefaultTasksURL, request)
        self.assertEqual(len(default.children), 0)

        yield self.abort()
开发者ID:eventable,项目名称:CalendarServer,代码行数:25,代码来源:test_resource.py

示例8: test_pick_default_addressbook

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
    def test_pick_default_addressbook(self):
        """
        Get adbk
        """

        request = SimpleStoreRequest(self, "GET", "/addressbooks/users/wsanchez/", authPrincipal=self.authPrincipal)
        home = yield request.locateResource("/addressbooks/users/wsanchez")

        # default property initially not present
        try:
            home.readDeadProperty(carddavxml.DefaultAddressBookURL)
        except HTTPError:
            pass
        else:
            self.fail("carddavxml.DefaultAddressBookURL is not empty")

        yield home.pickNewDefaultAddressBook(request)

        try:
            default = home.readDeadProperty(carddavxml.DefaultAddressBookURL)
        except HTTPError:
            self.fail("carddavxml.DefaultAddressBookURL is not present")
        else:
            self.assertEqual(str(default.children[0]), "/addressbooks/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/addressbook/")
开发者ID:nunb,项目名称:calendarserver,代码行数:26,代码来源:test_resource.py

示例9: test_wikiACL

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
    def test_wikiACL(self):
        """
        Ensure shareeAccessControlList( ) honors the access granted by the wiki
        to the sharee, so that delegates of the sharee get the same level of
        access.
        """

        access = "read"
        def stubWikiAccessMethod(userID, wikiID):
            return access
        self.patch(sharing, "getWikiAccess", stubWikiAccessMethod)

        sharedName = yield self.wikiSetup()
        request = SimpleStoreRequest(self, "GET", "/calendars/__uids__/user01/")
        collection = yield request.locateResource("/calendars/__uids__/user01/" + sharedName)

        # Simulate the wiki server granting Read access
        acl = (yield collection.shareeAccessControlList(request))
        self.assertFalse("<write/>" in acl.toxml())

        # Simulate the wiki server granting Read-Write access
        access = "write"
        acl = (yield collection.shareeAccessControlList(request))
        self.assertTrue("<write/>" in acl.toxml())
开发者ID:anemitz,项目名称:calendarserver,代码行数:26,代码来源:test_sharing.py

示例10: _getResourceSharer

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
 def _getResourceSharer(self, name):
     request = SimpleStoreRequest(self, "GET", "%s" % (name,))
     resource = yield request.locateResource("%s" % (name,))
     returnValue(resource)
开发者ID:nunb,项目名称:calendarserver,代码行数:6,代码来源:test_sharing.py

示例11: _getResource

# 需要导入模块: from twistedcaldav.test.util import SimpleStoreRequest [as 别名]
# 或者: from twistedcaldav.test.util.SimpleStoreRequest import locateResource [as 别名]
 def _getResource(self):
     request = SimpleStoreRequest(self, "GET", "/calendars/__uids__/user01/calendar/")
     resource = yield request.locateResource("/calendars/__uids__/user01/calendar/")
     returnValue(resource)
开发者ID:nunb,项目名称:calendarserver,代码行数:6,代码来源:test_sharing.py


注:本文中的twistedcaldav.test.util.SimpleStoreRequest.locateResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。