tests/testthat/test_dadapush_message_api.R

library(testthat)
library(DaDaPushClient)
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate

context("Test DaDaPushMessageApi")

# api_client <- ApiClient$new(basePath = "http://127.0.0.1:8080")
api_client <- ApiClient$new()
api <- DaDaPushMessageApi$new(api_client)

test_that("CreateMessage", {
    # tests for CreateMessage
    # base path: https://www.dadapush.com
    # push Message to a Channel
    # &lt;h2&gt;Rate Limit:&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;1 request per 1s&lt;/li&gt;&lt;li&gt;30 request per 1m&lt;/li&gt;&lt;li&gt;500 request per 1h&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Result code/errmsg List:&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;0: ok&lt;/li&gt;&lt;li&gt;1: server error&lt;/li&gt;&lt;li&gt;101: channel is exists&lt;/li&gt;&lt;li&gt;102: channel is not exists&lt;/li&gt;&lt;li&gt;103: channel token error&lt;/li&gt;&lt;li&gt;104: channel is not exists&lt;/li&gt;&lt;li&gt;105: message is not exists&lt;/li&gt;&lt;li&gt;204: bad request&lt;/li&gt;&lt;li&gt;205: permission deny&lt;/li&gt;&lt;li&gt;206: too many request, please after 5 minutes to try!&lt;/li&gt;&lt;li&gt;301: duplicate username/email&lt;/li&gt;&lt;li&gt;302: user is not exists&lt;/li&gt;&lt;li&gt;303: user password is error&lt;/li&gt;&lt;li&gt;304: client push token is error&lt;/li&gt;&lt;li&gt;305: user is disabled&lt;/li&gt;&lt;li&gt;306: your subscription is expired&lt;/li&gt;&lt;li&gt;307: user not subscribe channel&lt;/li&gt;&lt;/ul&gt;
    # @param MessagePushRequest  body  body
    # @param character  x.channel.token  see: https://www.dadapush.com/channel/list  (optional)
    # @return [ResultOfMessagePushResponse]

    # uncomment below to test the operation
    action <- Action$new(name = "view", url = "https://www.dadapush.com/", type = "link")
    body <- MessagePushRequest$new(title = "Good News!",
    content = "Good News! DaDaPush releasing new version",
    needPush = "true",
    actions = c(action)
    )
    response = api$CreateMessage(body,x.channel.token="ctb3lwO6AeiZOwqZgp8BE8980FdNgp0cp6MCf")
    print(response)
    #expect_equal(result, "EXPECTED_RESULT")
})

test_that("DeleteMessage", {
    # tests for DeleteMessage
    # base path: https://www.dadapush.com
    # delete a Channel Message
    # &lt;h2&gt;Rate Limit:&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;10 request per 1s&lt;/li&gt;&lt;li&gt;100 request per 1m&lt;/li&gt;&lt;li&gt;1000 request per 1h&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Result code/errmsg List:&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;0: ok&lt;/li&gt;&lt;li&gt;1: server error&lt;/li&gt;&lt;li&gt;101: channel is exists&lt;/li&gt;&lt;li&gt;102: channel is not exists&lt;/li&gt;&lt;li&gt;103: channel token error&lt;/li&gt;&lt;li&gt;104: channel is not exists&lt;/li&gt;&lt;li&gt;105: message is not exists&lt;/li&gt;&lt;li&gt;204: bad request&lt;/li&gt;&lt;li&gt;205: permission deny&lt;/li&gt;&lt;li&gt;206: too many request, please after 5 minutes to try!&lt;/li&gt;&lt;li&gt;301: duplicate username/email&lt;/li&gt;&lt;li&gt;302: user is not exists&lt;/li&gt;&lt;li&gt;303: user password is error&lt;/li&gt;&lt;li&gt;304: client push token is error&lt;/li&gt;&lt;li&gt;305: user is disabled&lt;/li&gt;&lt;li&gt;306: your subscription is expired&lt;/li&gt;&lt;li&gt;307: user not subscribe channel&lt;/li&gt;&lt;/ul&gt;
    # @param integer  message.id  messageId
    # @param character  x.channel.token  see: https://www.dadapush.com/channel/list  (optional)
    # @return [Result]

    # uncomment below to test the operation
    # response = api$DeleteMessage(message.id=227851,x.channel.token="ctb3lwO6AeiZOwqZgp8BE8980FdNgp0cp6MCf")
    # print(response)
    #expect_equal(result, "EXPECTED_RESULT")
})

test_that("GetMessage", {
    # tests for GetMessage
    # base path: https://www.dadapush.com
    # get a Channel Message
    # &lt;h2&gt;Rate Limit:&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;10 request per 1s&lt;/li&gt;&lt;li&gt;100 request per 1m&lt;/li&gt;&lt;li&gt;1000 request per 1h&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Result code/errmsg List:&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;0: ok&lt;/li&gt;&lt;li&gt;1: server error&lt;/li&gt;&lt;li&gt;101: channel is exists&lt;/li&gt;&lt;li&gt;102: channel is not exists&lt;/li&gt;&lt;li&gt;103: channel token error&lt;/li&gt;&lt;li&gt;104: channel is not exists&lt;/li&gt;&lt;li&gt;105: message is not exists&lt;/li&gt;&lt;li&gt;204: bad request&lt;/li&gt;&lt;li&gt;205: permission deny&lt;/li&gt;&lt;li&gt;206: too many request, please after 5 minutes to try!&lt;/li&gt;&lt;li&gt;301: duplicate username/email&lt;/li&gt;&lt;li&gt;302: user is not exists&lt;/li&gt;&lt;li&gt;303: user password is error&lt;/li&gt;&lt;li&gt;304: client push token is error&lt;/li&gt;&lt;li&gt;305: user is disabled&lt;/li&gt;&lt;li&gt;306: your subscription is expired&lt;/li&gt;&lt;li&gt;307: user not subscribe channel&lt;/li&gt;&lt;/ul&gt;
    # @param integer  message.id  messageId
    # @param character  x.channel.token  see: https://www.dadapush.com/channel/list  (optional)
    # @return [ResultOfMessageObject]

    # uncomment below to test the operation
    # response = api$GetMessage(message.id=227851,x.channel.token="ctb3lwO6AeiZOwqZgp8BE8980FdNgp0cp6MCf")
    # print(response)
    #expect_equal(result, "EXPECTED_RESULT")
})

test_that("GetMessages", {
    # tests for GetMessages
    # base path: https://www.dadapush.com
    # get Message List
    # &lt;h2&gt;Rate Limit:&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;1 request per 1s&lt;/li&gt;&lt;li&gt;45 request per 1m&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Result code/errmsg List:&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;0: ok&lt;/li&gt;&lt;li&gt;1: server error&lt;/li&gt;&lt;li&gt;101: channel is exists&lt;/li&gt;&lt;li&gt;102: channel is not exists&lt;/li&gt;&lt;li&gt;103: channel token error&lt;/li&gt;&lt;li&gt;104: channel is not exists&lt;/li&gt;&lt;li&gt;105: message is not exists&lt;/li&gt;&lt;li&gt;204: bad request&lt;/li&gt;&lt;li&gt;205: permission deny&lt;/li&gt;&lt;li&gt;206: too many request, please after 5 minutes to try!&lt;/li&gt;&lt;li&gt;301: duplicate username/email&lt;/li&gt;&lt;li&gt;302: user is not exists&lt;/li&gt;&lt;li&gt;303: user password is error&lt;/li&gt;&lt;li&gt;304: client push token is error&lt;/li&gt;&lt;li&gt;305: user is disabled&lt;/li&gt;&lt;li&gt;306: your subscription is expired&lt;/li&gt;&lt;li&gt;307: user not subscribe channel&lt;/li&gt;&lt;/ul&gt;
    # @param integer  page  greater than 1
    # @param integer  page.size  range is 1,50
    # @param character  x.channel.token  see: https://www.dadapush.com/channel/list  (optional)
    # @return [ResultOfPageResponseOfMessageObject]

    # uncomment below to test the operation
    # response = api$GetMessages(page=1,page.size=10,x.channel.token="ctb3lwO6AeiZOwqZgp8BE8980FdNgp0cp6MCf")
    # print(response)
    #expect_equal(result, "EXPECTED_RESULT")
})
dadapush/dadapush-r-client documentation built on Nov. 4, 2019, 9:36 a.m.