From c1b92fb0fa896af9cca4728b17ce0a42e90d0201 Mon Sep 17 00:00:00 2001 From: dbolotov Date: Wed, 9 Oct 2019 17:40:14 -0700 Subject: [PATCH] fixed notes and errors found by check_win and check_rhub --- .Rbuildignore | 1 + DESCRIPTION | 4 +-- NEWS.md | 2 +- R/cumulocityr.R | 2 +- tests/testthat/test_get_devices.R | 18 ------------ tests/testthat/test_get_events.R | 28 +----------------- tests/testthat/test_get_measurements.R | 39 +------------------------- 7 files changed, 7 insertions(+), 87 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index a7587ed..ab7e5e7 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,3 +9,4 @@ ^_pkgdown\.yml$ ^\.travis\.yml$ ^codecov\.yml$ +^vignettes/cumulocityr\.Rmd$ diff --git a/DESCRIPTION b/DESCRIPTION index a58c8a8..02fa3b1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: cumulocityr Type: Package -Title: R client for the Cumulocity API -Version: 0.1.0.9000 +Title: R Client for the Cumulocity API +Version: 0.1.0 Authors@R: c( person("Dmitriy", "Bolotov", email = "rpmmlsupport@softwareag.com", role = c("aut", "cre")), person("Software AG", role = c("cph"))) diff --git a/NEWS.md b/NEWS.md index 86a3f06..e4a4b23 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,3 @@ # cumulocityr 0.1.0 -* Added a `NEWS.md` file to track changes to the package. +* Added functions `get_devices`, `get_events`, and `get_measurements`. diff --git a/R/cumulocityr.R b/R/cumulocityr.R index 16bbefd..8fcac5a 100644 --- a/R/cumulocityr.R +++ b/R/cumulocityr.R @@ -17,7 +17,7 @@ # GNU General Public License for details (http://www.gnu.org/licenses/). # ############################################################################# -#' R client for the Cumulocity API +#' R Client for the Cumulocity API #' #' This package contains functions to interact with the Cumulocity API. #' diff --git a/tests/testthat/test_get_devices.R b/tests/testthat/test_get_devices.R index 35c7e2f..c328f4a 100644 --- a/tests/testthat/test_get_devices.R +++ b/tests/testthat/test_get_devices.R @@ -7,24 +7,6 @@ test_that("get_devices returns data.frame", { }) -# test_that("time is parsed or not depending on parse_datetime", { -# skip_on_cran() -# -# result_04 <- get_devices(num_rows = 2) -# result_05 <- get_devices(num_rows = 10, parse_datetime = FALSE) -# -# expect_true(inherits(result_04$creationTime[1], "POSIXlt")) -# expect_true(inherits(result_04$lastUpdated[1], "POSIXlt")) -# expect_true(inherits(result_04$c8y_Availability$lastMessage[1], "POSIXlt")) -# -# result_05_row <- result_05[which(result_05$id == .get_cumulocity_device_id()), ] -# -# expect_true(is.character(result_05_row$creationTime[1])) -# expect_true(is.character(result_05_row$lastUpdated[1])) -# expect_true(is.character(result_05_row$c8y_Availability.lastMessage[1])) -# }) - - test_that("parse_json = FALSE returns character string", { skip_on_cran() diff --git a/tests/testthat/test_get_events.R b/tests/testthat/test_get_events.R index 5291191..3267646 100644 --- a/tests/testthat/test_get_events.R +++ b/tests/testthat/test_get_events.R @@ -3,7 +3,6 @@ context("test get_events") test_that("page_size controls number of records returned", { skip_on_cran() - # results used in test_get_events.R result_06 <- get_events( device_id = .get_cumulocity_device_id(), date_from = "2019-09-30T20:00:00Z", @@ -20,32 +19,6 @@ test_that("page_size controls number of records returned", { expect_equal(NROW(result_07), 4) }) -# test_that("time is parsed or not depending on parse_datetime", { -# skip_on_cran() -# -# result_06 <- get_events( -# device_id = .get_cumulocity_device_id(), -# date_from = "2019-09-30T20:00:00Z", -# num_rows = 2 -# ) -# -# result_07 <- get_events( -# device_id = .get_cumulocity_device_id(), -# date_from = "2019-09-30T20:00:00Z", -# num_rows = 4, parse_datetime = FALSE -# ) -# -# expect_true(inherits(result_06$time[1], "POSIXlt")) -# expect_true(is.character(result_07$time[1])) -# }) - -# test_that("warning message is issued when measurements list is empty", { -# skip_on_cran() -# expect_warning(get_events(123, date_from = "2019-09-30T20:00:00Z"), -# "No events found on page 1.", -# fixed = TRUE -# ) -# }) test_that("parse_json = FALSE returns character string", { skip_on_cran() @@ -61,6 +34,7 @@ test_that("parse_json = FALSE returns character string", { test_that("when num_rows is NULL, return all records between two dates", { + skip_on_cran() result_11 <- get_events( device_id = .get_cumulocity_device_id(), date_from = "2019-09-30T00:00:00Z", date_to = "2019-10-01T04:40:10Z" diff --git a/tests/testthat/test_get_measurements.R b/tests/testthat/test_get_measurements.R index 78ea79d..b97e4e5 100644 --- a/tests/testthat/test_get_measurements.R +++ b/tests/testthat/test_get_measurements.R @@ -20,27 +20,8 @@ test_that("page_size controls number of records returned", { expect_equal(NROW(result_02), 11) }) -# test_that("time is parsed or not depending on parse_datetime", { -# skip_on_cran() -# -# result_01 <- get_measurements( -# device_id = .get_cumulocity_device_id(), -# date_from = "2019-09-30T20:00:00Z", -# num_rows = 2 -# ) -# -# result_02 <- get_measurements( -# device_id = .get_cumulocity_device_id(), -# date_from = "2019-09-30T20:00:00Z", -# num_rows = 11, parse_datetime = FALSE -# ) -# -# expect_true(inherits(result_01$time[1], "POSIXlt")) -# expect_true(is.character(result_02$time[1])) -# }) - - test_that("when num_rows is NULL, return all records between two dates", { + skip_on_cran() result_10 <- get_measurements( device_id = .get_cumulocity_device_id(), date_from = "2019-10-01T00:00:00Z", date_to = "2019-10-01T00:00:10Z" @@ -48,24 +29,6 @@ test_that("when num_rows is NULL, return all records between two dates", { expect_equal(NROW(result_10), 2) }) -# test_that("what happens when num_rows is very large but there is only data on page 1?", { -# get_measurements(device_id = .get_cumulocity_device_id(), -# date_from = "2019-10-01T02:00:00Z") -# }) - - - -# test_that("warning message is issued when measurements list is empty", { -# skip_on_cran() -# # Measurements list is empty because the device_id does not exist. -# expect_warning(get_measurements( -# device_id = 123, -# date_from = "2019-09-30T20:00:00Z" -# ), -# "No measurements found on page 1.", -# fixed = TRUE -# ) -# }) test_that("parse_json = FALSE returns character string", { skip_on_cran()