66ab9af19636a33f96e257eebbdf3fa0813add72
[arvados.git] / sdk / R / tests / testthat / test-HttpRequest.R
1 context("Http Request")
2
3
4 test_that("execyte raises exception if http verb is not valid", {
5
6     http <- HttpRequest$new()
7     expect_that(http$execute("FAKE VERB", "url"),
8                throws_error("Http verb is not valid."))
9 }) 
10
11 test_that(paste("createQuery generates and encodes query portion of http",
12                 "request based on filters, limit and offset parameters"), {
13
14     http <- HttpRequest$new()
15     filters <- list(list("color", "=", "red"))
16     limit <- 20
17     offset <- 50
18     expect_that(http$createQuery(filters, limit, offset),
19                 equals(paste0("/?filters=%5B%5B%22color%22%2C%22%3D%22%2C%22red",
20                               "%22%5D%5D&limit=20&offset=50")))
21 }) 
22
23 test_that(paste("createQuery generates and empty string",
24                 "when filters, limit and offset parameters are set to NULL"), {
25
26     http <- HttpRequest$new()
27     expect_that(http$createQuery(NULL, NULL, NULL), equals(""))
28 })