Skip to content

Commit

Permalink
Quantcast: Fix for empty video parameters (#4145)
Browse files Browse the repository at this point in the history
* Copy params from bid.params.video.

* Added test for missing video parameters.

* Include mimes from adunit.
  • Loading branch information
dpapworth-qc authored and bretg committed Sep 8, 2019
1 parent 02cd6e4 commit 69107fe
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 17 deletions.
19 changes: 18 additions & 1 deletion modules/quantcastBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,24 @@ function extractBidSizes(bid) {
}

function makeVideoImp(bid) {
const video = bid.params.video;
const video = {};
if (bid.params.video) {
video['mimes'] = bid.params.video.mimes;
video['minduration'] = bid.params.video.minduration;
video['maxduration'] = bid.params.video.maxduration;
video['protocols'] = bid.params.video.protocols;
video['startdelay'] = bid.params.video.startdelay;
video['linearity'] = bid.params.video.linearity;
video['battr'] = bid.params.video.battr;
video['maxbitrate'] = bid.params.video.maxbitrate;
video['playbackmethod'] = bid.params.video.playbackmethod;
video['delivery'] = bid.params.video.delivery;
video['placement'] = bid.params.video.placement;
video['api'] = bid.params.video.api;
}
if (bid.mediaTypes.video.mimes) {
video['mimes'] = bid.mediaTypes.video.mimes;
}
if (utils.isArray(bid.mediaTypes.video.playerSize[0])) {
video['w'] = bid.mediaTypes.video.playerSize[0][0];
video['h'] = bid.mediaTypes.video.playerSize[0][1];
Expand Down
96 changes: 80 additions & 16 deletions test/spec/modules/quantcastBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,11 @@ describe('Quantcast adapter', function () {
};
});

function setupVideoBidRequest() {
function setupVideoBidRequest(videoParams) {
bidRequest.params = {
publisherId: 'test-publisher', // REQUIRED - Publisher ID provided by Quantcast
// Video object as specified in OpenRTB 2.5
video: {
mimes: ['video/mp4'], // required
minduration: 3, // optional
maxduration: 5, // optional
protocols: [3], // optional
startdelay: 1, // optional
linearity: 1, // optinal
battr: [1, 2], // optional
maxbitrate: 10, // optional
playbackmethod: [1], // optional
delivery: [1], // optional
placement: 1, // optional
api: [2, 3] // optional
}
video: videoParams
};
bidRequest['mediaTypes'] = {
video: {
Expand Down Expand Up @@ -162,7 +149,20 @@ describe('Quantcast adapter', function () {
});

it('sends video bid requests containing all the required parameters', function () {
setupVideoBidRequest();
setupVideoBidRequest({
mimes: ['video/mp4'], // required
minduration: 3, // optional
maxduration: 5, // optional
protocols: [3], // optional
startdelay: 1, // optional
linearity: 1, // optinal
battr: [1, 2], // optional
maxbitrate: 10, // optional
playbackmethod: [1], // optional
delivery: [1], // optional
placement: 1, // optional
api: [2, 3] // optional
});

const requests = qcSpec.buildRequests([bidRequest], bidderRequest);
const expectedVideoBidRequest = {
Expand Down Expand Up @@ -203,6 +203,70 @@ describe('Quantcast adapter', function () {
expect(requests[0].data).to.equal(JSON.stringify(expectedVideoBidRequest));
});

it('overrides video parameters with parameters from adunit', function() {
setupVideoBidRequest({
mimes: ['video/mp4']
});
bidRequest.mediaTypes.video.mimes = ['video/webm'];

const requests = qcSpec.buildRequests([bidRequest], bidderRequest);
const expectedVideoBidRequest = {
publisherId: QUANTCAST_TEST_PUBLISHER,
requestId: '2f7b179d443f14',
imp: [
{
video: {
mimes: ['video/webm'],
w: 600,
h: 300
},
placementCode: 'div-gpt-ad-1438287399331-0',
bidFloor: 1e-10
}
],
site: {
page: 'http://example.com/hello.html',
referrer: 'http://example.com/hello.html',
domain: 'example.com'
},
bidId: '2f7b179d443f14',
gdprSignal: 0,
prebidJsVersion: '$prebid.version$'
};

expect(requests[0].data).to.equal(JSON.stringify(expectedVideoBidRequest));
});

it('sends video bid request when no video parameters are given', function () {
setupVideoBidRequest(null);

const requests = qcSpec.buildRequests([bidRequest], bidderRequest);
const expectedVideoBidRequest = {
publisherId: QUANTCAST_TEST_PUBLISHER,
requestId: '2f7b179d443f14',
imp: [
{
video: {
w: 600,
h: 300
},
placementCode: 'div-gpt-ad-1438287399331-0',
bidFloor: 1e-10
}
],
site: {
page: 'http://example.com/hello.html',
referrer: 'http://example.com/hello.html',
domain: 'example.com'
},
bidId: '2f7b179d443f14',
gdprSignal: 0,
prebidJsVersion: '$prebid.version$'
};

expect(requests[0].data).to.equal(JSON.stringify(expectedVideoBidRequest));
});

it('ignores unsupported video bid requests', function () {
bidRequest.mediaTypes = {
video: {
Expand Down

0 comments on commit 69107fe

Please sign in to comment.