blob: 883b10c177514c71f253691adbea1d0362fe27ec [file] [log] [blame]
Marc Kupietz5d9e3a22020-03-23 09:03:29 +01001test_that("KorAPConnection is printable", {
2 kco <- new("KorAPConnection")
3 expect_error(print(kco), NA)
4})
5
6test_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
11test_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
24test_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})