Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Video Indexer v2 #66

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

noce2
Copy link

@noce2 noce2 commented Nov 12, 2018

To ensure the getAccounts method of v2 of the video indexer api is working properly, I have written a unit test. As the video indexer has a large API, I wanted to do a small PR to check that my approach is correct before I plough ahead with the rest of the work.

@noce2 noce2 changed the title Adds get accounts endpoint on v2 of video indexer Add Authorization Endpoints on v2 of video indexer Nov 14, 2018
@miparnisari
Copy link
Collaborator

Thanks @noce2! The 4 tests pass. Only nitpick is the missing catch in the beforeEach. Please fix that and I'll merge.

@cornu-ammonis
Copy link

@miparnisari @noce2 I was going to open a PR for this myself but this looks done. If I were to add the catch on the beforeEachwould this still be mergeable?

@vatsal2210
Copy link

Hi @miparnisari, can you close this open request? It would be great for me to continue. Moreover, I tried to look around any file/folder for indexer under vision folder. But I didn't find any.

@miparnisari
Copy link
Collaborator

@noce2 can you review my comment and fix the merge conflict?

@noce2
Copy link
Author

noce2 commented Jun 6, 2019

sure :)

* @param {boolean} obj.allowEdit
* @returns {Promise<[Object]>} A promise containing an array of objects
*/
getAccounts({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this specific to the video indexer api? If not, can we pull this out into a separate file?

throw new Error('no video to upload. A video must be specified, either via videoUrl or a path');
}

const pathToVideo = (params.path) ? params.path : params.videoUrl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be simplified via params.path || params.videoUrl?


const pathToVideo = (params.path) ? params.path : params.videoUrl;

const isFormatSupported = this.supportedFormats.filter(sf => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this covered by tests?

*/
uploadVideo(params){
if(!params.path && !params.videoUrl) {
throw new Error('no video to upload. A video must be specified, either via videoUrl or a path');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this covered by tests?


if(params.videoUrl && !((/(http)s?(:\/\/)/).test(params.videoUrl))){
// video should point to public url
throw new Error('videoUrl is not an http/https link. A videoUrl must contain a public path');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this covered by tests?

apiKey: config.videoIndexerV2.apiKey
});

const videoUrl = 'https://mparnisari.blob.core.windows.net/storage/video_girl_laughing.mp4';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used?

client.getUserAccessToken(requestParams)
.then(response => {
should(response).not.be.undefined();
should(response).startWith("ey", "the encoding of brackets alwys generates this at the start");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in alwys

client.getAccountAccessToken(requestParams)
.then(response => {
should(response).not.be.undefined();
should(response).startWith("ey", "the encoding of brackets alwys generates this at the start");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in alwys


const requestHeaders = {};

if(params.videoUrl && !((/(http)s?(:\/\/)/).test(params.videoUrl))){
Copy link
Collaborator

@miparnisari miparnisari Jun 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line and line 190 can be simplified: if(<regex>.test(pathToVideo)). No need to do this check twice

* Uploads a video to the Video Indexer
*/
uploadVideo(params){
if(!params.path && !params.videoUrl) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I specify both? Which will be used?

const videoUrl = 'https://mparnisari.blob.core.windows.net/storage/video_girl_laughing.mp4';
const videoPath = './test/assets/video_girl_laughing.mp4';

describe('Get Accounts', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like having several describes in one file. It makes it harder to run just once suite of tests. If the Auth API is specific to the Video Indexer API, please only have one describe. Else, move them to a separate test file.

})
})

describe.only('Upload Video', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove .only

@miparnisari miparnisari changed the title Add Authorization Endpoints on v2 of video indexer Add Video Indexer v2 Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants