Example #1
0
def test_write(api):
    """POST method for cybozulive.com"""
    # Confirm single item.
    n = Notification(id='GROUP,1:1,BOARD,1:1',
            updated=NOW.strftime('%Y-%m-%dT%H:%M:%SZ'))
    #api.notification(confirm=n)
    # Confirm multiple items.
    #api.notification(confirm=[Notification(id='GROUP,1:1,CABINET,1:1'),
    #    Notification(id='GROUP,1:1,TASK,1:1')])

    # create a new topic!! it has not id yet.
    for i in range(2):
        delta = timedelta(i)
        n = (NOW - delta).strftime("%Y-%m-%dT%H:%M:%SZ")
        topic = Board(title=u"No.%d: API 経由での投稿です" % (i + 1,),
                    summary=u"いろはにほへと" +
                        u"ちりぬるを わかよたれそ" +
                        u"つねならむ ういのおくやま けふこえて" +
                        u"あさきゆめみし えいもせず",
                    updated=n)
        api.board("1:1", topic=topic)

    # create comment on specific item.
    c = Comment(parent=Board(id='GROUP,1:1,BOARD,1:1'),
            summary=u"コメント書き込みAPIのテストです。")
    api.comment(comment=c)

    # edit a existing item.
    topic = Board(id='GROUP,1:1,BOARD,1:1',
                title=u"API 経由で変更しました",
                summary=u"あいうえお",
                updated=NOW.strftime("%Y-%m-%dT%H:%M:%SZ"))
    api.board("1:1", topic=topic)
Example #2
0
def test_sync(api):
    """Experimental method for cybozulive.com"""
    n = NOW.strftime("%Y-%m-%dT%H:%M:%SZ")
    data = [
        ["GROUP,1:1,GW_SCHEDULE,1:1", n],
        ["GROUP,1:1,GW_SCHEDULE,1:2", n],
        ["GROUP,1:2,GW_SCHEDULE,1:10", n],
        ["MYPAGE,1:1,MP_SCHEDULE,1:1", n],
        ["MYPAGE,1:1,MP_SCHEDULE,1:2", n]]

    feed = etree.Element('{%s}feed' % (ATOM_NAMESPACE, ))
    title = etree.Element('{%s}title' % (ATOM_NAMESPACE, ))
    title.text = 'DIFF'
    feed.append(title)

    for item in data:
        entry = create_entry(id=item[0], updated=item[1])
        feed.append(entry)
        # TODO: use this entity instead of calling access() directly.
        e = Schedule(id=item[0], updated=item[1])
    api.access("scheduleSync", data=etree.tostring(feed))

    data = [
        ["GROUP,1:1,GW_SCHEDULE,1:1", "CREATED"],
        ["GROUP,1:1,GW_SCHEDULE,1:2", "NOTFOUND"],
        ["GROUP,1:2,GW_SCHEDULE,1:10", "UPDATED"]]

    feed = etree.Element('{%s}feed' % (ATOM_NAMESPACE, ))
    title = etree.Element('{%s}title' % (ATOM_NAMESPACE, ))
    title.text = 'SYNC'
    feed.append(title)

    for item in data:
        entry = create_entry(id=item[0], title=item[1])
        feed.append(entry)
        # TODO: use this entity instead of calling access() directly.
        e = Schedule(id=item[0], updated=item[1])
    api.access("scheduleSync", data=etree.tostring(feed))
Example #3
0
 def debug(self, s):
     logging.debug("%s %s" % (s, NOW()))