Do not run tests that download videos on CI

Travis get blacklisted by more and more services (Vimeo, Youtube, etc.)
This commit is contained in:
Pierre Rudloff 2019-10-26 16:13:08 +02:00
parent 9427a22a41
commit 1cab9623e9
9 changed files with 48 additions and 46 deletions

View file

@ -45,4 +45,29 @@ abstract class BaseTest extends TestCase
{
Config::destroyInstance();
}
/**
* Check tests requirements.
* @return void
*/
protected function checkRequirements()
{
parent::checkRequirements();
$annotations = $this->getAnnotations();
$requires = [];
if (isset($annotations['class']['requires'])) {
$requires += $annotations['class']['requires'];
}
if (isset($annotations['method']['requires'])) {
$requires += $annotations['method']['requires'];
}
foreach ($requires as $require) {
if ($require == 'download' && getenv('CI')) {
$this->markTestSkipped('Do not run tests that download videos on CI.');
}
}
}
}

View file

@ -11,6 +11,7 @@ use Alltube\Video;
/**
* Unit tests for the ConvertedPlaylistArchiveStream class.
* @requires download
*/
class ConvertedPlaylistArchiveStreamTest extends StreamTest
{

View file

@ -11,6 +11,7 @@ use Alltube\Controller\DownloadController;
/**
* Unit tests for the FrontController class.
* @requires download
*/
class DownloadControllerTest extends ControllerTest
{
@ -79,10 +80,6 @@ class DownloadControllerTest extends ControllerTest
*/
public function testDownloadWithM3uStream()
{
if (getenv('CI')) {
$this->markTestSkipped('Twitter returns a 429 error when the test is ran too many times.');
}
Config::setOptions(['stream' => true]);
$this->assertRequestIsOk(
@ -153,9 +150,6 @@ class DownloadControllerTest extends ControllerTest
*/
public function testDownloadWithMissingPassword()
{
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$this->assertRequestIsRedirect('download', ['url' => 'http://vimeo.com/68375962']);
}

View file

@ -108,6 +108,7 @@ class FrontControllerTest extends ControllerTest
* Test the info() function.
*
* @return void
* @requires download
*/
public function testInfo()
{
@ -118,6 +119,7 @@ class FrontControllerTest extends ControllerTest
* Test the info() function with audio conversion.
*
* @return void
* @requires download
*/
public function testInfoWithAudio()
{
@ -133,12 +135,10 @@ class FrontControllerTest extends ControllerTest
* Test the info() function with audio conversion from a Vimeo video.
*
* @return void
* @requires download
*/
public function testInfoWithVimeoAudio()
{
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
Config::setOptions(['convert' => true]);
// So we can test the fallback to default format
@ -149,6 +149,7 @@ class FrontControllerTest extends ControllerTest
* Test the info() function with audio enabled and an URL that doesn't need to be converted.
*
* @return void
* @requires download
*/
public function testInfoWithUnconvertedAudio()
{
@ -167,12 +168,10 @@ class FrontControllerTest extends ControllerTest
* Test the info() function with a password.
*
* @return void
* @requires download
*/
public function testInfoWithPassword()
{
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$result = $this->controller->info(
$this->request->withQueryParams(['url' => 'http://vimeo.com/68375962'])
->withParsedBody(['password' => 'youtube-dl']),
@ -185,12 +184,10 @@ class FrontControllerTest extends ControllerTest
* Test the info() function with a missing password.
*
* @return void
* @requires download
*/
public function testInfoWithMissingPassword()
{
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$this->assertRequestIsOk('info', ['url' => 'http://vimeo.com/68375962']);
$this->assertRequestIsOk('info', ['url' => 'http://vimeo.com/68375962', 'audio' => true]);
}
@ -199,6 +196,7 @@ class FrontControllerTest extends ControllerTest
* Test the info() function with streams enabled.
*
* @return void
* @requires download
*/
public function testInfoWithStream()
{
@ -215,6 +213,7 @@ class FrontControllerTest extends ControllerTest
* Test the info() function with a playlist.
*
* @return void
* @requires download
*/
public function testInfoWithPlaylist()
{

View file

@ -27,6 +27,7 @@ class JsonControllerTest extends ControllerTest
* Test the json() function.
*
* @return void
* @requires download
*/
public function testJson()
{
@ -37,6 +38,7 @@ class JsonControllerTest extends ControllerTest
* Test the json() function with an error.
*
* @return void
* @requires download
*/
public function testJsonWithError()
{

View file

@ -11,6 +11,7 @@ use Alltube\Video;
/**
* Unit tests for the PlaylistArchiveStream class.
* @requires download
*/
class PlaylistArchiveStreamTest extends StreamTest
{

View file

@ -11,6 +11,7 @@ use Alltube\Video;
/**
* Unit tests for the Video class.
* @requires download
*/
class VideoTest extends BaseTest
{
@ -58,10 +59,6 @@ class VideoTest extends BaseTest
*/
public function testgetUrlWithPassword()
{
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$video = new Video('http://vimeo.com/68375962', 'best', 'youtube-dl');
foreach ($video->getUrl() as $videoURL) {
$this->assertContains('vimeocdn.com', $videoURL);
@ -76,10 +73,6 @@ class VideoTest extends BaseTest
*/
public function testgetUrlWithMissingPassword()
{
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$video = new Video('http://vimeo.com/68375962');
$video->getUrl();
}
@ -92,10 +85,6 @@ class VideoTest extends BaseTest
*/
public function testgetUrlWithWrongPassword()
{
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$video = new Video('http://vimeo.com/68375962', 'best', 'foo');
$video->getUrl();
}
@ -148,17 +137,13 @@ class VideoTest extends BaseTest
'mp4',
'openload.co',
],
];
if (!getenv('CI')) {
// Travis is blacklisted by Vimeo.
$videos[] = [
[
'https://vimeo.com/24195442', 'best[protocol^=http]',
'Carving_the_Mountains-24195442',
'mp4',
'vimeocdn.com',
]
];
}
return $videos;
}
@ -187,17 +172,14 @@ class VideoTest extends BaseTest
*/
public function m3uUrlProvider()
{
$videos = [];
if (!getenv('CI')) {
// Twitter returns a 429 error when the test is ran too many times.
$videos[] = [
$videos = [
[
'https://twitter.com/verge/status/813055465324056576/video/1', 'hls-2176',
'The_Verge_-_This_tiny_origami_robot_can_self-fold_and_complete_tasks-813055465324056576',
'mp4',
'video.twimg.com',
]
];
}
return $videos;
}
@ -359,10 +341,6 @@ class VideoTest extends BaseTest
*/
public function testGetAudioStreamDashError()
{
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$video = new Video('https://vimeo.com/251997032', 'bestaudio/best');
$video->getAudioStream();
}

View file

@ -11,6 +11,7 @@ use Alltube\Video;
/**
* Unit tests for the YoutubeChunkStream class.
* @requires download
*/
class YoutubeChunkStreamTest extends StreamTest
{

View file

@ -11,6 +11,7 @@ use Alltube\Video;
/**
* Unit tests for the YoutubeStream class.
* @requires download
*/
class YoutubeStreamTest extends StreamTest
{