Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update API endpoint URLs #3283

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/api/tests/test.auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ context("Testing authentication for API")

test_that("Using correct username & password returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/models/",
"http://pecan.localhost/api/models/",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Using incorrect username & password returns Status 401", {
res <- httr::GET(
"http://localhost:8000/api/models/",
"http://pecan.localhost/api/models/",
httr::authenticate("carya", "wrong_password")
)
expect_equal(res$status, 401)
})

test_that("Not using username & password returns Status 401", {
res <- httr::GET(
"http://localhost:8000/api/models/",
"http://pecan.localhost/api/models/",
)
expect_equal(res$status, 401)
})
8 changes: 4 additions & 4 deletions apps/api/tests/test.formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ context("Testing all formats related endpoints")

test_that("Calling /api/formats/ with valid parameters returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/formats/?format_name=ameriflux&mimetype=csv&ignore_case=TRUE",
"http://pecan.localhost/api/formats/?format_name=ameriflux&mimetype=csv&ignore_case=TRUE",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/formats/ with invalid parameters returns Status 404", {
res <- httr::GET(
"http://localhost:8000/api/formats/?format_name=random&mimetype=random&ignore_case=TRUE",
"http://pecan.localhost/api/formats/?format_name=random&mimetype=random&ignore_case=TRUE",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
})

test_that("Calling /api/formats/{format_id} returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/formats/19",
"http://pecan.localhost/api/formats/19",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/formats/{format_id} with invalid parameters returns Status 404", {
res <- httr::GET(
"http://localhost:8000/api/formats/0",
"http://pecan.localhost/api/formats/0",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
Expand Down
12 changes: 6 additions & 6 deletions apps/api/tests/test.inputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@ context("Testing all inputs related endpoints")

test_that("Calling /api/inputs/ with valid parameters returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/inputs/?model_id=1000000022&site_id=676",
"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://localhost:8000/api/inputs/?model_id=0&site_id=0",
"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://localhost:8000/api/inputs/", 99000000003),
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://localhost:8000/api/inputs/0",
"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://localhost:8000/api/inputs/295?filename=fraction.plantation"),
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://localhost:8000/api/inputs/295?filename=random",
"http://pecan.localhost/api/inputs/295?filename=random",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 400)
Expand Down
8 changes: 4 additions & 4 deletions apps/api/tests/test.models.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ context("Testing all models endpoints")

test_that("Calling /api/models/ returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/models/?model_name=SIPNET&revision=ssr",
"http://pecan.localhost/api/models/?model_name=SIPNET&revision=ssr",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/models/ with invalid parameters returns Status 404", {
res <- httr::GET(
"http://localhost:8000/api/models/?model_name=random&revision=random",
"http://pecan.localhost/api/models/?model_name=random&revision=random",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
})

test_that("Calling /api/models/{model_id} returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/models/1000000014",
"http://pecan.localhost/api/models/1000000014",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/models/{model_id} with invalid parameters returns Status 404", {
res <- httr::GET(
"http://localhost:8000/api/models/1",
"http://pecan.localhost/api/models/1",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
Expand Down
8 changes: 4 additions & 4 deletions apps/api/tests/test.pfts.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ context("Testing all PFTs endpoints")

test_that("Calling /api/pfts/ returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/pfts/?pft_name=temperate&pft_type=plant&model_type=sipnet",
"http://pecan.localhost/api/pfts/?pft_name=temperate&pft_type=plant&model_type=sipnet",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/pfts/ with invalid parameters returns Status 404", {
res <- httr::GET(
"http://localhost:8000/api/pfts/?pft_name=random&model_type=random",
"http://pecan.localhost/api/pfts/?pft_name=random&model_type=random",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
})

test_that("Calling /api/pfts/{pft_id} returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/pfts/2000000045",
"http://pecan.localhost/api/pfts/2000000045",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/pfts/{pft_id} with invalid parameters returns Status 404", {
res <- httr::GET(
"http://localhost:8000/api/pfts/0",
"http://pecan.localhost/api/pfts/0",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
Expand Down
2 changes: 1 addition & 1 deletion apps/api/tests/test.ping.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
context("Testing the /api/ping endpoint")

test_that("Calling /api/ping returns Status 200", {
res <- httr::GET("http://localhost:8000/api/ping")
res <- httr::GET("http://pecan.localhost/api/ping")
expect_equal(res$status, 200)
})
20 changes: 10 additions & 10 deletions apps/api/tests/test.runs.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ context("Testing all runs endpoints")

test_that("Calling /api/runs/ with a valid workflow id returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/runs/?workflow_id=1000009172",
"http://pecan.localhost/api/runs/?workflow_id=1000009172",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
Expand All @@ -12,71 +12,71 @@ test_that("Calling /api/runs/ with a valid workflow id returns Status 200", {

test_that("Calling /api/runs/{id} with a valid run id returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/runs/1002042201",
"http://pecan.localhost/api/runs/1002042201",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/runs/ with a invalid workflow id returns Status 404", {
res <- httr::GET(
"http://localhost:8000/api/runs/?workflow_id=1000000000",
"http://pecan.localhost/api/runs/?workflow_id=1000000000",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
})

test_that("Calling /api/runs/{id} with a invalid run id returns Status 404", {
res <- httr::GET(
"http://localhost:8000/api/runs/1000000000",
"http://pecan.localhost/api/runs/1000000000",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
})

test_that("Calling /api/runs/{run_id}/graph/{year}/{yvar}/ with valid inputs returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/runs/99000000282/graph/2002/GPP",
"http://pecan.localhost/api/runs/99000000282/graph/2002/GPP",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/runs/{run_id}/graph/{year}/{yvar}/ with valid inputs returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/runs/1000000000/graph/100/GPP",
"http://pecan.localhost/api/runs/1000000000/graph/100/GPP",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
})

test_that("Calling /api/runs/{run_id}/input/{filename} with valid inputs returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/runs/99000000282/input/sipnet.in",
"http://pecan.localhost/api/runs/99000000282/input/sipnet.in",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/runs/{run_id}/input/{filename} with valid inputs returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/runs/1000000000/input/randomfile",
"http://pecan.localhost/api/runs/1000000000/input/randomfile",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
})

test_that("Calling /api/runs/{run_id}/output/{filename} with valid inputs returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/runs/99000000282/output/2002.nc",
"http://pecan.localhost/api/runs/99000000282/output/2002.nc",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/runs/{run_id}/output/{filename} with valid inputs returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/runs/1000000000/output/randomfile",
"http://pecan.localhost/api/runs/1000000000/output/randomfile",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
Expand Down
8 changes: 4 additions & 4 deletions apps/api/tests/test.sites.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ context("Testing all sites endpoints")

test_that("Calling /api/sites/ returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/sites/?sitename=washington",
"http://pecan.localhost/api/sites/?sitename=washington",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/sites/ with invalid parameters returns Status 404", {
res <- httr::GET(
"http://localhost:8000/api/sites/?sitename=random",
"http://pecan.localhost/api/sites/?sitename=random",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
})

test_that("Calling /api/sites/{site_id} returns Status 200", {
res <- httr::GET(
"http://localhost:8000/api/sites/676",
"http://pecan.localhost/api/sites/676",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 200)
})

test_that("Calling /api/sites/{site_id} with invalid parameters returns Status 404", {
res <- httr::GET(
"http://localhost:8000/api/sites/0",
"http://pecan.localhost/api/sites/0",
httr::authenticate("carya", "illinois")
)
expect_equal(res$status, 404)
Expand Down
Loading
Loading