tests/testthat/test_get_adverts.R

library(adParser)
library(testthat)
context("Get adverts functions")

test_that("get ad url works",
          {
            urls <- get_ad_urls("../../inst/rawdata/webpages/gumtree_main.html",
                                "gumtree")
            expect_equal(urls[1],
                         "/s-ad/maryborough/dogs-puppies/purebred-chihuahua/1090925867")
          }
)

test_that("get ads works",
          {
            expect_error(get_ads(n = 1, page = "google", animal = "dog",
                                 dir = ".", save_html = FALSE),
                         "No info for that page animal combo")
            expect_error(get_ads(n = 1, page = "gumtree", animal = "lemur",
                                 dir = ".", save_html = FALSE),
                         "No info for that page animal combo")
#             n <- get_ads(n = 1, page = "tradingpost",
#                     animal = "dog", dir = '.',
#                     save_html = FALSE, trace = FALSE)
#             expect_equal(n, 20)
          }
)
jonotuke/adParser documentation built on May 19, 2019, 8:34 p.m.