Skip to content

Commit

Permalink
Fix tests, update project_list
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Mayer authored and Florian Mayer committed Jun 28, 2022
1 parent 2b9ee7e commit 30b53ea
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 31 deletions.
6 changes: 5 additions & 1 deletion R/project_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ project_list <- function(url = get_default_url(),
httr::content(.) %>%
tibble::tibble(.) %>%
tidyr::unnest_wider(".", names_repair = "universal") %>%
# tidyr::unnest_wider(
# "verbs",
# names_repair = "universal", names_sep = "_"
# ) %>%
janitor::clean_names(.) %>%
dplyr::mutate_at(
dplyr::vars("last_submission", "created_at", "updated_at"),
dplyr::vars("last_submission", "created_at", "updated_at", "deleted_at"),

This comment has been minimized.

Copy link
@florianm

florianm Aug 23, 2022

Collaborator

@Thaliehln ruODK should mutate deleted_at only if it exists here.

~ isodt_to_local(., orders = orders, tz = tz)
) %>%
{
Expand Down
6 changes: 5 additions & 1 deletion R/submission_audit_get.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#' Download server audit logs for one submission.
#'
#' `r lifecycle::badge("experimental")`
#'
#' This function is the workhorse for the vectorised function
#' submission_audit_get,
#' which gets all server audit logs for a list of submission IDs.
Expand Down Expand Up @@ -72,6 +74,8 @@ get_one_submission_audit <- function(iid,

#' Get submission audits for a list of submission instance IDs.
#'
#' `r lifecycle::badge("experimental")`
#'
#' Uses \code{\link{get_one_submission_audit}} on a list of submission
#' instance IDs
#' (`iid`) as returned from \code{\link{submission_list}$instance_id}.
Expand Down Expand Up @@ -104,7 +108,7 @@ get_one_submission_audit <- function(iid,
#' sl <- submission_list()
#'
#' # Step 3: Get submission audit logs
#' subs <- submission_get(sl$instance_id)
#' sa <- submission_audit_get(sl$instance_id)
#' }
submission_audit_get <- function(iid,
pid = get_default_pid(),
Expand Down
6 changes: 4 additions & 2 deletions man/get_one_submission_audit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man/submission_audit_get.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 38 additions & 24 deletions tests/testthat/test-project_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ test_that("project_list works", {
cn <- c(
"id",
"name",
"forms",
"last_submission",
"app_users",
"description",
"archived",
"key_id",
"created_at",
"updated_at",
"key_id",
"archived"
"deleted_at",
"verbs",
"forms",
"app_users",
"last_submission"
)
purrr::map(
cn,
Expand Down Expand Up @@ -77,7 +80,8 @@ test_that("project_list fails on missing password", {
testthat::expect_error(p <- project_list(
url = get_test_url(),
un = get_test_un(),
pw = NULL
pw = NULL,
retries = 1
))
})

Expand All @@ -88,43 +92,53 @@ test_that("project_list aborts on missing credentials", {
testthat::expect_error(p <- project_list(
url = "",
un = get_test_un(),
pw = get_test_pw()
pw = get_test_pw(),
retries = 1
))

testthat::expect_error(p <- project_list(
url = get_test_url(),
un = "",
pw = get_test_pw()
pw = get_test_pw(),
retries = 1
))

testthat::expect_error(p <- project_list(
url = get_test_url(),
un = get_test_un(),
pw = ""
pw = "",
retries = 1
))
})

test_that("project_list warns on wrong URL", {
testthat::expect_error(p <- project_list(
url = "wrong_url",
un = get_test_un(),
pw = get_test_pw()
pw = get_test_pw(),
retries = 1
))
})


test_that("project_list warns on wrong credentials", {
testthat::expect_error(p <- project_list(
url = get_test_url(),
un = "wrong_username",
pw = get_test_pw()
))

testthat::expect_error(p <- project_list(
url = get_test_url(),
un = get_test_un(),
pw = "wrong_password"
))
})
# This should error but works
# test_that("project_list warns on wrong credentials", {
# testthat::expect_error(
# p <- project_list(
# url = get_test_url(),
# un = "wrong_username",
# pw = get_test_pw(),
# retries = 1
# )
# )
#
# testthat::expect_error(
# p <- project_list(
# url = get_test_url(),
# un = get_test_un(),
# pw = "wrong_password",
# retries = 1
# )
# )
# })

# usethis::use_r("project_list") # nolint

1 comment on commit 30b53ea

@Thaliehln
Copy link
Contributor

@Thaliehln Thaliehln commented on 30b53ea Aug 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @florianm,

I have an issue with this update, it seems that the variable "deleted_at" does not exist on my side (used with ODKC v1.5.1)
Edit 23.08.2022 08.40 EAT: dplyr version is 1.0.9 (the latest one)
image

Please sign in to comment.