#############################
## Testing searchForPodcast
#############################
test_that('A test to check if an error is raised on entering invalid arguments',
{
expect_error(searchForPodcast(1))
expect_error(searchForPodcast('History',market = 7))
expect_error(searchForPodcast('Philosophy',explicit = 'G'))
expect_error(searchForPodcast('Formula 1',limit = 100))
expect_error(searchForPodcast('EPL',language = 'GGGGG'))
})
#test_response_elm <- searchForPodcast(keywords = 'History',
# language = 'ES',
# market = 'ES',
# explicit = FALSE)
#test_response_el_t <- searchForPodcast(keywords = 'History',
# explicit = TRUE,
# limit = 10)
test_that('Checking whether the output is of type data.frame',
{
expect_equal(class(searchForPodcast(keywords = 'History',
language = 'ES',
market = 'ES',
explicit = FALSE)),'data.frame')
})
test_that('Checking filters',
{
expect_false(any(searchForPodcast(keywords = 'History',
language = 'ES',
market = 'ES',
explicit = FALSE)$Explicit==TRUE))
expect_false(any(searchForPodcast(keywords = 'History',
language = 'ES',
market = 'ES',
explicit = FALSE)$language!='es'))
expect_equal(nrow(searchForPodcast(keywords = 'History',
limit = 5)),5)
})
#### Testing getPodcastID Function ####
test_that(' A test to check if an error is raised on entering invalid arguments',
{
expect_error(getPodcastID('Philosophize This!',market = 7))
expect_error(getPodcastID('Philosophize This!', market='AAA'))
expect_error(getPodcastID(1, market='AAA'))
})
test_that('A test to check whether a valid podcast ID is returned',
{
expect_equal(getPodcastID('Philosophize This!'),'2Shpxw7dPoxRJCdfFXTWLE')
expect_equal(getPodcastID('Conspiracy Theories Parcast'),'5RdShpOtxKO3ZWohR2M6Sv')
})
#### Testing getRecentEpisodes Function ####
test_that('A test to check if an error is raised on entering invalid arguments',
{
expect_error(getRecentEpisodes(1))
expect_error(getRecentEpisodes('2Shpxw7dPoxRJCdfFXTWLE',market = 7))
expect_error(getRecentEpisodes('2Shpxw7dPoxRJCdfFXTWLE',explicit = 'G'))
expect_error(getRecentEpisodes('2Shpxw7dPoxRJCdfFXTWLE',limit = 100))
expect_error(getRecentEpisodes('2Shpxw7dPoxRJCdfFXTWLE',duration = 'TwentyMinutes'))
})
#test_response_eld_t <- getRecentEpisodes(podcast_id = '2FLQbu3SLMIrRIDM0CaiHG',
# duration = 40)
#test_response_e_f <- getRecentEpisodes(podcast_id = '2FLQbu3SLMIrRIDM0CaiHG',
# explicit = FALSE)
test_that('Checking whether the output is of type data.frame',
{
expect_equal(class(getRecentEpisodes(podcast_id = '2FLQbu3SLMIrRIDM0CaiHG')),'data.frame')
})
test_that('Checking filters',
{
#expect_false(any(test_response_e_f$Explicit==TRUE)) ##### please check this function
expect_true(any(getRecentEpisodes(podcast_id = '2FLQbu3SLMIrRIDM0CaiHG',
duration = 40)$Explicit==TRUE))
expect_false(any(getRecentEpisodes(podcast_id = '2FLQbu3SLMIrRIDM0CaiHG',
duration = 40)$Duration>40))
expect_equal(nrow(getRecentEpisodes(podcast_id = '2FLQbu3SLMIrRIDM0CaiHG',
limit = 5)),5)
})
#### Testing getEpisodeInformation Function ####
test_that('A test to check if an error is raised on entering invalid arguments',
{
expect_error(getEpisodeInformation(1))
expect_error(getEpisodeInformation('1'))
expect_error(getEpisodeInformation('3xUldphixY3rZnjxhfMxCK',market = 7))
})
test_that('Checking the output',
{
expect_equal(class(getEpisodeInformation(episode_id = '3xUldphixY3rZnjxhfMxCK')),'data.frame')
expect_equal(getEpisodeInformation(episode_id = '3xUldphixY3rZnjxhfMxCK')$episode_name,
'Chris Chan: A Comprehensive History - Part 42')
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.