Implement more tests

Close #47
This commit is contained in:
Mattia 2020-08-15 15:32:01 +02:00
parent f8eaa278b3
commit 56b4816d46
5 changed files with 31 additions and 12 deletions

View File

@ -51,7 +51,12 @@ class VideoClient {
Future<Video> _getVideoFromFixPlaylist(VideoId id) async {
var playlistInfo = await PlaylistResponse.get(_httpClient, 'RD${id.value}');
var video = playlistInfo.videos.firstWhere((e) => e.id == id.value);
var video = playlistInfo.videos
.firstWhere((e) => e.id == id.value, orElse: () => null);
if (video == null) {
throw TransientFailureException('Video not found in mix playlist');
}
return Video(
id,

View File

@ -18,7 +18,7 @@ void main() {
var channel = await yt.channels.get(ChannelId(channelUrl));
expect(channel.url, channelUrl);
expect(channel.title, 'Tyrrrz');
expect(channel.logoUrl, isNotNull);
expect(channel.logoUrl, isNotEmpty);
expect(channel.logoUrl, isNot(equalsIgnoringWhitespace('')));
});
@ -70,5 +70,13 @@ void main() {
.toList();
expect(videos, isNotEmpty);
});
test('GetVideosOfYoutubeChannelFromUploadPage', () async {
var videos = await yt.channels
.getUploadsFromPage('UCEnBXANsKmyj2r9xVyKoDiQ')
.take(30)
.toList();
expect(videos, hasLength(30));
});
});
}

View File

@ -33,8 +33,8 @@ void main() {
var captionPart =
caption.getPartByTime(const Duration(milliseconds: 650));
expect(caption, isNotNull);
expect(captionPart, isNotNull);
expect(caption, isNotEmpty);
expect(captionPart, isNotEmpty);
expect(caption.text, 'know I worked really hard on not doing');
expect(captionPart.text, ' hard');
});

View File

@ -24,6 +24,11 @@ void main() {
expect(playlist.engagement.viewCount, greaterThanOrEqualTo(133));
expect(playlist.engagement.likeCount, greaterThanOrEqualTo(0));
expect(playlist.engagement.dislikeCount, greaterThanOrEqualTo(0));
expect(playlist.thumbnails.lowResUrl, isNotEmpty);
expect(playlist.thumbnails.mediumResUrl, isNotEmpty);
expect(playlist.thumbnails.highResUrl, isNotEmpty);
expect(playlist.thumbnails.standardResUrl, isNotEmpty);
expect(playlist.thumbnails.maxResUrl, isNotEmpty);
});
test('GetMetadataOfAnyPlaylist', () async {
var data = {

View File

@ -18,16 +18,17 @@ void main() {
expect(video.id.value, 'AI7ULzgf8RU');
expect(video.url, videoUrl);
expect(video.title, 'Aka no Ha [Another] +HDHR');
expect(video.channelId.value, 'UCEnBXANsKmyj2r9xVyKoDiQ');
expect(video.author, 'Tyrrrz');
expect(video.uploadDate, DateTime(2017, 09, 30));
expect(video.uploadDate, DateTime(2017, 09, 30, 19, 15, 26));
expect(video.description, contains('246pp'));
expect(video.duration, const Duration(minutes: 1, seconds: 48));
expect(video.thumbnails.lowResUrl, isNotNull);
expect(video.thumbnails.mediumResUrl, isNotNull);
expect(video.thumbnails.highResUrl, isNotNull);
expect(video.thumbnails.standardResUrl, isNotNull);
expect(video.thumbnails.maxResUrl, isNotNull);
expect(video.keywords, orderedEquals(['osu', 'mouse', 'rhythm game']));
expect(video.duration, const Duration(minutes: 1, seconds: 49));
expect(video.thumbnails.lowResUrl, isNotEmpty);
expect(video.thumbnails.mediumResUrl, isNotEmpty);
expect(video.thumbnails.highResUrl, isNotEmpty);
expect(video.thumbnails.standardResUrl, isNotEmpty);
expect(video.thumbnails.maxResUrl, isNotEmpty);
expect(video.keywords, orderedEquals(['osu', 'mouse', '"rhythm game"']));
expect(video.engagement.viewCount, greaterThanOrEqualTo(134));
expect(video.engagement.likeCount, greaterThanOrEqualTo(5));
expect(video.engagement.dislikeCount, greaterThanOrEqualTo(0));