tests/testthat/test_update_project.R

"dwapi-r
Copyright 2017 data.world, Inc.

Licensed under the Apache License, Version 2.0 (the \"License\");
you may not use this file except in compliance with the License.

You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an \"AS IS\" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.

This product includes software developed at data.world, Inc.
https://data.world"

dw_test_that("update_project making the correct HTTR request", {
  request <- dwapi::project_update_request(
    objective = "UPDATED DESCRIPTION !")
  response <- with_mock(
    `httr::PATCH` = function(url, body, header, user_agent)  {
      expect_equal(url,
                   "https://api.data.world/v0/projects/ownerid/datasetid")
      expect_equal(header$headers[["Authorization"]], "Bearer API_TOKEN")
      expect_equal(body, rjson::toJSON(request))
      expect_equal(user_agent$options$useragent, user_agent())
      return(success_message_response())
    },
    `mime::guess_type` = function(...)
      NULL,
    dwapi::update_project("ownerid/datasetid",
                          project_update_req = request)
  )
  expect_equal(class(response), "success_message")
})

Try the dwapi package in your browser

Any scripts or data that you put into this service are public.

dwapi documentation built on May 1, 2019, 11:18 p.m.