예제 #1
0
def test_basic_push():  # type: () -> None
    instanlation = leancloud.Installation()
    instanlation.set('deviceType', 'ios')
    instanlation.set('deviceToken', 'xxx')
    instanlation.save()

    data = {
        "alert": {
            "title": "标题",
            "title-loc-key": "",
            "body": "消息内容",
            "action-loc-key": "",
            "loc-key": "",
            "loc-args": [""],
            "launch-image": "",
        }
    }
    query = leancloud.Query('_Installation').equal_to('objectId', 'xxx')
    notification = push.send(data, where=query, push_time=datetime.now())
    notification.fetch()
    assert(notification.id)

    try:
        notification.save()
    except leancloud.LeanCloudError as e:
        assert e.code == 1
    else:
        raise Exception()
예제 #2
0
def test_basic_push():  # type: () -> None
    installation = leancloud.Installation()
    installation.set('deviceType', 'ios')
    installation.set('deviceToken', 'xxx')
    installation.save()

    data = {
        "alert": {
            "title": "标题",
            "title-loc-key": "",
            "body": "消息内容",
            "action-loc-key": "",
            "loc-key": "",
            "loc-args": [""],
            "launch-image": "",
        }
    }
    query = leancloud.Query('_Installation').equal_to('objectId', 'xxx')
    now = datetime.now()
    two_hours_later = now + timedelta(hours=2)
    notification = push.send(data, where=query, push_time=now, expiration_time=two_hours_later)
    time.sleep(5)  # notification write may have delay
    notification.fetch()
    assert notification.id

    try:
        notification.save()
    except leancloud.LeanCloudError as e:
        assert e.code == 1
    else:
        raise Exception()
예제 #3
0
def test_basic_push():  # type: () -> None
    instanlation = leancloud.Installation()
    instanlation.set('deviceType', 'ios')
    instanlation.set('deviceToken', 'xxx')
    instanlation.save()

    data = {
        "alert": {
            "title": "标题",
            "title-loc-key": "",
            "body": "消息内容",
            "action-loc-key": "",
            "loc-key": "",
            "loc-args": [""],
            "launch-image": "",
        }
    }
    query = leancloud.Query('_Installation').equal_to('objectId', 'xxx')
    notification = push.send(data, where=query, push_time=datetime.now())
    time.sleep(5)  # notification write may have delay
    notification.fetch()
    assert(notification.id)

    try:
        notification.save()
    except leancloud.LeanCloudError as e:
        assert e.code == 1
    else:
        raise Exception()
예제 #4
0
def test_basic_push():
    data = {
        "alert": {
            "title": "标题",
            "title-loc-key": "",
            "body": "消息内容",
            "action-loc-key": "",
            "loc-key": "",
            "loc-args": [""],
            "launch-image": "",
        }
    }
    notification = push.send(data)
    notification.fetch()
    print notification.attributes
예제 #5
0
def test_basic_push():
    data = {
        "alert": {
            "title": "标题",
            "title-loc-key": "",
            "body": "消息内容",
            "action-loc-key": "",
            "loc-key": "",
            "loc-args": [""],
            "launch-image": "",
        }
    }
    query = leancloud.Query('_Installation').equal_to('objectId', 'xxx')
    notification = push.send(data, where=query)
    notification.fetch()
예제 #6
0
def test_basic_push():
    data = {
        "alert": {
            "title": "标题",
            "title-loc-key": "",
            "body": "消息内容",
            "action-loc-key": "",
            "loc-key": "",
            "loc-args": [""],
            "launch-image": "",
        }
    }
    query = leancloud.Query('_Installation').equal_to('objectId', 'xxx')
    notification = push.send(data, where=query)
    notification.fetch()
예제 #7
0
def test_basic_push():  # type: () -> None
    installation = leancloud.Installation()
    installation.set("deviceType", "ios")
    installation.set("deviceToken", "xxx")
    installation.save()

    data = {
        "alert": {
            "title": "标题",
            "title-loc-key": "",
            "body": "消息内容",
            "action-loc-key": "",
            "loc-key": "",
            "loc-args": [""],
            "launch-image": "",
        }
    }
    query = leancloud.Query("_Installation").equal_to("deviceToken", "xxx")
    now = datetime.now()
    two_hours_later = now + timedelta(hours=2)
    try:
        notification = push.send(
            data,
            where=query,
            push_time=now,
            expiration_time=two_hours_later,
            prod="dev",
            flow_control=0,
        )
    except leancloud.LeanCloudError as e:
        # LeanCloudError: [1] The iOS certificate file is expired or disabled.
        assert e.code == 1
    else:
        # flow_control = 0 <=> flow_control = 1000 by rest api design
        time.sleep(5)  # notification write may have delay
        notification.fetch()
        assert notification.id
        # Test that notification is read only.
        try:
            notification.save()
        except leancloud.LeanCloudError as e:
            assert e.code == 1
        else:
            raise Exception()
예제 #8
0
def test_basic_push():
    instanlation = leancloud.Installation()
    instanlation.set('deviceType', 'ios')
    instanlation.set('deviceToken', 'xxx')
    instanlation.save()

    data = {
        "alert": {
            "title": "标题",
            "title-loc-key": "",
            "body": "消息内容",
            "action-loc-key": "",
            "loc-key": "",
            "loc-args": [""],
            "launch-image": "",
        }
    }
    query = leancloud.Query('_Installation').equal_to('objectId', 'xxx')
    notification = push.send(data, where=query)
예제 #9
0
def test_basic_push():
    instanlation = leancloud.Installation()
    instanlation.set('deviceType', 'ios')
    instanlation.set('deviceToken', 'xxx')
    instanlation.save()

    data = {
        "alert": {
            "title": "标题",
            "title-loc-key": "",
            "body": "消息内容",
            "action-loc-key": "",
            "loc-key": "",
            "loc-args": [""],
            "launch-image": "",
        }
    }
    query = leancloud.Query('_Installation').equal_to('objectId', 'xxx')
    notification = push.send(data, where=query)