tests/testthat/test-pf_view_photos.R

context("test-pf_view_photos")

if(file.exists("token.txt")) {
  token <- readLines("token.txt")
}

test_that("pf_view_photos works", {
  expect_error(pf_view_photos(animal_df = puppies, size = 123))
  expect_error(pf_view_photos(animal_df = puppies, size = "abc"))
  
  skip_if_not(exists("token"))
  df <- pf_find_pets(token, type = "dog", limit = 3)
  output <- pf_view_photos(df, "small")
  expect_true(tibble::is_tibble(magick::image_info(output)))
  
  photo_cols <- grepl(pattern = "photo", x = names(df))
  df[,photo_cols] <- NA
  expect_error(pf_view_photos(df, "small"))
})
earl88/PetFindr documentation built on Jan. 18, 2020, 9:10 a.m.