tests/testthat/test_get_team_info_by_id.R

context("test get_team_info_by_team_id is working")

test_that('function get_team_info_by_team_id works properly', {

 skip_on_cran()
 skip_on_travis()

 #fails if no key is provided and key has not been set
 expect_error(get_team_info_by_team_id(language = 'en',
                                       key = NULL),
              'The function cannot find an API key.')

 #registering key
 key_actions('register_key', Sys.getenv('RDota_KEY'))
 expect_error(get_team_info_by_team_id(language = 'en',
                                       key = NULL),
              NA)

 #make sure url contains the right path
 expect_true(grepl('GetTeamInfoByTeamID',
                   get_team_info_by_team_id()$url))

 #make sure response received i.e. api working
 expect_equal(get_team_info_by_team_id()$response$status_code,
              200L)

 #make sure user_agent has been set properly
 expect_identical(
  get_team_info_by_team_id()$response$request$options$useragent, 'http://github.com/lyzander/RDota2'
 )

 #make sure function returned a results list
 expect_true(is.list(get_team_info_by_team_id()$content))

 #delete key
 key_actions('delete_key')

})

Try the RDota2 package in your browser

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

RDota2 documentation built on May 1, 2019, 7:09 p.m.