2017-08-05 13:48:53 -07:00
|
|
|
package builders
|
|
|
|
|
|
|
|
import (
|
2017-08-13 14:50:59 -07:00
|
|
|
"context"
|
2017-08-05 13:48:53 -07:00
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2019-01-06 12:38:46 -08:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2017-08-19 16:58:23 -07:00
|
|
|
"github.com/mxpv/podsync/pkg/api"
|
2017-11-03 16:04:33 -07:00
|
|
|
"github.com/mxpv/podsync/pkg/model"
|
2017-08-05 13:48:53 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2017-08-13 14:50:59 -07:00
|
|
|
vimeoKey = os.Getenv("VIMEO_TEST_API_KEY")
|
2017-08-05 13:48:53 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestQueryVimeoChannel(t *testing.T) {
|
2019-01-06 12:38:46 -08:00
|
|
|
if vimeoKey == "" {
|
|
|
|
t.Skip("Vimeo API key is not provided")
|
|
|
|
}
|
|
|
|
|
2017-08-05 13:48:53 -07:00
|
|
|
builder, err := NewVimeoBuilder(context.Background(), vimeoKey)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-05-07 21:29:20 -07:00
|
|
|
podcast := &model.Feed{ItemID: "staffpicks", Quality: api.QualityHigh}
|
|
|
|
err = builder.queryChannel(podcast)
|
2017-08-05 13:48:53 -07:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-05-07 21:29:20 -07:00
|
|
|
require.Equal(t, "https://vimeo.com/channels/staffpicks", podcast.ItemURL)
|
2017-08-05 13:48:53 -07:00
|
|
|
require.Equal(t, "Vimeo Staff Picks", podcast.Title)
|
2019-05-07 21:29:20 -07:00
|
|
|
require.Equal(t, "Vimeo Curation", podcast.Author)
|
2017-08-05 13:48:53 -07:00
|
|
|
require.NotEmpty(t, podcast.Description)
|
2019-05-07 21:29:20 -07:00
|
|
|
require.NotEmpty(t, podcast.CoverArt)
|
2017-08-05 13:48:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestQueryVimeoGroup(t *testing.T) {
|
2019-01-06 12:38:46 -08:00
|
|
|
if vimeoKey == "" {
|
|
|
|
t.Skip("Vimeo API key is not provided")
|
|
|
|
}
|
|
|
|
|
2017-08-05 13:48:53 -07:00
|
|
|
builder, err := NewVimeoBuilder(context.Background(), vimeoKey)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-05-07 21:29:20 -07:00
|
|
|
podcast := &model.Feed{ItemID: "motion", Quality: api.QualityHigh}
|
|
|
|
err = builder.queryGroup(podcast)
|
2017-08-05 13:48:53 -07:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-05-07 21:29:20 -07:00
|
|
|
require.Equal(t, "https://vimeo.com/groups/motion", podcast.ItemURL)
|
2017-08-05 13:48:53 -07:00
|
|
|
require.Equal(t, "Motion Graphic Artists", podcast.Title)
|
2019-05-07 21:29:20 -07:00
|
|
|
require.Equal(t, "Danny Garcia", podcast.Author)
|
2017-08-05 13:48:53 -07:00
|
|
|
require.NotEmpty(t, podcast.Description)
|
2019-05-07 21:29:20 -07:00
|
|
|
require.NotEmpty(t, podcast.CoverArt)
|
2017-08-05 13:48:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestQueryVimeoUser(t *testing.T) {
|
2019-01-06 12:38:46 -08:00
|
|
|
if vimeoKey == "" {
|
|
|
|
t.Skip("Vimeo API key is not provided")
|
|
|
|
}
|
|
|
|
|
2017-08-05 13:48:53 -07:00
|
|
|
builder, err := NewVimeoBuilder(context.Background(), vimeoKey)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-05-07 21:29:20 -07:00
|
|
|
podcast := &model.Feed{ItemID: "motionarray", Quality: api.QualityHigh}
|
|
|
|
err = builder.queryUser(podcast)
|
2017-08-05 13:48:53 -07:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-05-07 21:29:20 -07:00
|
|
|
require.Equal(t, "https://vimeo.com/motionarray", podcast.ItemURL)
|
2017-08-05 13:48:53 -07:00
|
|
|
require.Equal(t, "Motion Array", podcast.Title)
|
2019-05-07 21:29:20 -07:00
|
|
|
require.Equal(t, "Motion Array", podcast.Author)
|
2017-08-05 13:48:53 -07:00
|
|
|
require.NotEmpty(t, podcast.Description)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQueryVimeoVideos(t *testing.T) {
|
2019-01-06 12:38:46 -08:00
|
|
|
if vimeoKey == "" {
|
|
|
|
t.Skip("Vimeo API key is not provided")
|
|
|
|
}
|
|
|
|
|
2017-08-05 13:48:53 -07:00
|
|
|
builder, err := NewVimeoBuilder(context.Background(), vimeoKey)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-05-07 21:29:20 -07:00
|
|
|
feed := &model.Feed{ItemID: "staffpicks"}
|
2017-08-05 13:48:53 -07:00
|
|
|
|
2019-05-07 21:29:20 -07:00
|
|
|
err = builder.queryVideos(builder.client.Channels.ListVideo, feed)
|
2017-08-05 13:48:53 -07:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-05-07 21:29:20 -07:00
|
|
|
require.Equal(t, vimeoDefaultPageSize, len(feed.Episodes))
|
2017-08-05 13:48:53 -07:00
|
|
|
|
2019-05-07 21:29:20 -07:00
|
|
|
for _, item := range feed.Episodes {
|
2017-08-05 13:48:53 -07:00
|
|
|
require.NotEmpty(t, item.Title)
|
2019-05-07 21:29:20 -07:00
|
|
|
require.NotEmpty(t, item.VideoURL)
|
|
|
|
require.NotEmpty(t, item.ID)
|
|
|
|
require.NotEmpty(t, item.Thumbnail)
|
|
|
|
require.NotZero(t, item.Duration)
|
|
|
|
require.NotZero(t, item.Size)
|
2017-08-05 13:48:53 -07:00
|
|
|
}
|
|
|
|
}
|