sample
}
-RListToPythonList <- function(sample, separator = ", ")
+RListToPythonList <- function(RList, separator = ", ")
{
- pythonArrayContent <- sapply(sample, function(sampleUnit)
+ pythonArrayContent <- sapply(RList, function(elementInList)
{
- if((is.vector(sampleUnit) || is.list(sampleUnit)) &&
- length(sampleUnit) > 1)
+ if((is.vector(elementInList) || is.list(elementInList)) &&
+ length(elementInList) > 1)
{
- return(RListToPythonList(sampleUnit, separator))
+ return(RListToPythonList(elementInList, separator))
}
else
{
- return(paste0("\"", sampleUnit, "\""))
+ return(paste0("\"", elementInList, "\""))
}
})
- return(paste0("[", paste0(pythonArrayContent, collapse = separator), "]"))
+ pythonArray <- paste0("[", paste0(pythonArrayContent, collapse = separator), "]")
+ pythonArray
}
appendToStartIfNotExist <- function(sample, characters)
--- /dev/null
+context("Http Parser")
+
+
+test_that(paste("createQuery generates and encodes query portion of http",
+ "request based on filters, limit and offset parameters"), {
+
+ http <- HttpRequest$new()
+ filters <- list(list("color", "=", "red"))
+ limit <- 20
+ offset <- 50
+ expect_that(http$createQuery(filters, limit, offset),
+ equals(paste0("/?filters=%5B%5B%22color%22%2C%22%3D%22%2C%22red",
+ "%22%5D%5D&limit=20&offset=50")))
+})
+
+test_that(paste("createQuery generates and empty string",
+ "when filters, limit and offset parameters are set to NULL"), {
+
+ http <- HttpRequest$new()
+ expect_that(http$createQuery(NULL, NULL, NULL), equals(""))
+})