Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame^] | 1 | test_that("KorAPConnection is printable", { |
| 2 | kco <- new("KorAPConnection") |
| 3 | expect_error(print(kco), NA) |
| 4 | }) |
| 5 | |
| 6 | test_that("KorAPConnection without access token prints ToS message", { |
| 7 | expect_message(new("KorAPConnection", accessToken = NULL), |
| 8 | ".*By using.*non-commercial.*purposes", perl = TRUE) |
| 9 | }) |
| 10 | |
| 11 | test_that("Opening KorAPConnection with apiToken works", { |
| 12 | kco <- new("KorAPConnection", accessToken="test token") |
| 13 | persistAccessToken(kco) |
| 14 | kco <- new("KorAPConnection") |
| 15 | expect_equal(kco@accessToken, "test token") |
| 16 | clearAccessToken(kco) |
| 17 | kco <- new("KorAPConnection") |
| 18 | expect_null(kco@accessToken) |
| 19 | expect_error(persistAccessToken(kco), |
| 20 | ".*not supplied any access token.*", |
| 21 | perl = TRUE) |
| 22 | }) |
| 23 | |
| 24 | test_that("Opening KorAPConnection with KorAPUrl works", { |
| 25 | kco <- new("KorAPConnection", KorAPUrl="https://korap.ids-mannheim.de") |
| 26 | expect_equal(kco@apiUrl, paste0("https://korap.ids-mannheim.de/api/", kco@apiVersion, "/")) |
| 27 | kco <- new("KorAPConnection", KorAPUrl="https://korap.ids-mannheim.de/") |
| 28 | expect_equal(kco@apiUrl, paste0("https://korap.ids-mannheim.de/api/", kco@apiVersion, "/")) |
| 29 | }) |