def test_okLink(self):
        resource = CalendarHomeResource(self.site.resource, "home", object(), StubHome())
        self.site.resource.putChild("home", resource)
        link = LinkResource(resource, "/home/outbox/")
        resource.putChild("link", link)

        request = SimpleRequest(self.site, "GET", "/home/link/")
        linked_to, _ignore = (yield resource.locateChild(request, ["link", ]))
        self.assertTrue(linked_to is resource.getChild("outbox"))
    def test_badLink(self):
        resource = CalendarHomeResource(self.site.resource, "home", object(), StubHome())
        self.site.resource.putChild("home", resource)
        link = LinkResource(resource, "/home/outbox/abc")
        resource.putChild("link", link)

        request = SimpleRequest(self.site, "GET", "/home/link/")
        try:
            yield resource.locateChild(request, ["link", ])
        except HTTPError, e:
            self.assertEqual(e.response.code, responsecode.NOT_FOUND)
Example #3
0
    def test_badLink(self):
        resource = CalendarHomeResource(self.site.resource, "home", object(), StubHome())
        self.site.resource.putChild("home", resource)
        link = LinkResource(resource, "/home/outbox/abc")
        resource.putChild("link", link)

        request = SimpleRequest(self.site, "GET", "/home/link/")
        try:
            yield resource.locateChild(request, ["link", ])
        except HTTPError, e:
            self.assertEqual(e.response.code, responsecode.NOT_FOUND)
Example #4
0
    def test_okLink(self):
        resource = CalendarHomeResource(self.site.resource, "home", object(), StubHome())
        self.site.resource.putChild("home", resource)
        link = LinkResource(resource, "/home/outbox/")
        resource.putChild("link", link)

        request = SimpleRequest(self.site, "GET", "/home/link/")
        linked_to, _ignore = (yield resource.locateChild(request, ["link", ]))
        self.assertTrue(linked_to is resource.getChild("outbox"))
Example #5
0
    def test_recursiveLink(self):
        resource = CalendarHomeResource(self.site.resource, "home", object(), StubHome())
        self.site.resource.putChild("home", resource)
        link1 = LinkResource(resource, "/home/link2/")
        resource.putChild("link1", link1)
        link2 = LinkResource(resource, "/home/link1/")
        resource.putChild("link2", link2)

        request = SimpleRequest(self.site, "GET", "/home/link1/")
        try:
            yield resource.locateChild(request, ["link1", ])
        except HTTPError, e:
            self.assertEqual(e.response.code, responsecode.LOOP_DETECTED)
    def test_recursiveLink(self):
        resource = CalendarHomeResource(self.site.resource, "home", object(), StubHome())
        self.site.resource.putChild("home", resource)
        link1 = LinkResource(resource, "/home/link2/")
        resource.putChild("link1", link1)
        link2 = LinkResource(resource, "/home/link1/")
        resource.putChild("link2", link2)

        request = SimpleRequest(self.site, "GET", "/home/link1/")
        try:
            yield resource.locateChild(request, ["link1", ])
        except HTTPError, e:
            self.assertEqual(e.response.code, responsecode.LOOP_DETECTED)
Example #7
0
            sys.exit(1)

    for opt, arg in optargs:
        if opt in ("-h", "--help"):
            usage()

        elif opt in ("-f", "--config"):
            configFileName = arg

        elif opt in ("-a", "--all"):
            allRecords = True

        elif opt in ("-H", "--home"):
            path = abspath(arg)
            parent = CalDAVFile(dirname(abspath(path)))
            calendarHome = CalendarHomeResource(arg, parent, dummyDirectoryRecord)
            checkExists(calendarHome)
            calendarHomes.add(calendarHome)

        elif opt in ("-r", "--record"):
            try:
                recordType, shortName = arg.split(":", 1)
                if not recordType or not shortName:
                    raise ValueError()
            except ValueError:
                sys.stderr.write("Invalid record identifier: %r\n" % (arg,))
                sys.exit(1)

            records.add((recordType, shortName))

        elif opt in ("-u", "--user"):
Example #8
0
 def test_calendarHomeliveProperties(self):
     resource = CalendarHomeResource(None, None, None, StubHome())
     self.assertTrue(('http://calendarserver.org/ns/',
                      'push-transports') in resource.liveProperties())
     self.assertTrue(('http://calendarserver.org/ns/',
                      'pushkey') in resource.liveProperties())
Example #9
0
 def test_calendarHomeliveProperties(self):
     resource = CalendarHomeResource(None, None, None, StubHome())
     self.assertTrue(('http://calendarserver.org/ns/', 'push-transports') in resource.liveProperties())
     self.assertTrue(('http://calendarserver.org/ns/', 'pushkey') in resource.liveProperties())