-
Notifications
You must be signed in to change notification settings - Fork 240
/
test.inputs.R
49 lines (43 loc) · 1.57 KB
/
test.inputs.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
context("Testing all inputs related endpoints")
test_that("Calling /api/inputs/ with valid parameters returns Status 200", {
res <- httr::GET(
"http://pecan.localhost/api/inputs/?model_id=1000000022&site_id=676",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})
test_that("Calling /api/inputs/ with invalid parameters returns Status 404", {
res <- httr::GET(
"http://pecan.localhost/api/inputs/?model_id=0&site_id=0",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
})
test_that("Calling /api/inputs/{input_id} with valid parameters returns Status 200", {
res <- httr::GET(
paste0("http://pecan.localhost/api/inputs/", 99000000003),
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})
test_that("Calling /api/inputs/{input_id} with invalid parameters returns Status 404", {
res <- httr::GET(
"http://pecan.localhost/api/inputs/0",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
})
test_that("Calling /api/inputs/{input_id}?filename={filename} with valid parameters returns Status 200", {
res <- httr::GET(
paste0("http://pecan.localhost/api/inputs/295?filename=fraction.plantation"),
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})
test_that("Calling /api/inputs/{input_id}?filename={filename} with invalid parameters returns Status 404", {
res <- httr::GET(
"http://pecan.localhost/api/inputs/295?filename=random",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 400)
})