tests/testthat/test_metadata.R

context("Test retrieval of metadata")

test_that("Domain search ranking can be retrieved", {
  token <- whoapi_token("demokey")
  result <- try({domain_rank(token, "whoapi.com")}, silent = TRUE)
  if(!"try-error" %in% class(result)){
    expect_that(is.list(result), equals(TRUE))
    expect_true(all(c("status","alexa_reach","alexa_popularity","alexa_linksin",
                      "email", "title") %in% names(result)))
  }
})

test_that("domain search results can be retrieved", {
  token <- whoapi_token("demokey")
  result <- try({domain_search(token, "whoapi.com")}, silent = TRUE)
  if(!"try-error" %in% class(result)){
    expect_that(is.list(result), equals(TRUE))
    expect_that(names(result), equals(c("status","google_results","bing_results")))
  }
})

test_that("Metadata (in the HTML sense) can be retrieved", {
  token <- whoapi_token("demokey")
  result <- try({domain_metadata(token, "whoapi.com")}, silent = TRUE)
  if(!"try-error" %in% class(result)){
    expect_that(is.list(result), equals(TRUE))
    expect_that(names(result), equals(c("status","title","description")))
  }
})

test_that("Geolocation info can be retrieved", {
  token <- whoapi_token("demokey")
  result <- try({domain_location(token, "whoapi.com")}, silent = TRUE)
  if(!"try-error" %in% class(result)){
    expect_that(is.list(result), equals(TRUE))
    expect_that(names(result), equals(c("status","ip","geo_cc","geo_country","geo_city", "geo_latitude", "geo_longitude")))
  }
})

Try the whoapi package in your browser

Any scripts or data that you put into this service are public.

whoapi documentation built on May 2, 2019, 6:44 a.m.