-
Notifications
You must be signed in to change notification settings - Fork 801
RP adapter: use video placement parameter to set size ID #1607
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -489,7 +489,8 @@ func (a *RubiconAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder * | |
rubiReq.Device = &deviceCopy | ||
|
||
if thisImp.Video != nil { | ||
videoExt := rubiconVideoExt{Skip: params.Video.Skip, SkipDelay: params.Video.SkipDelay, RP: rubiconVideoExtRP{SizeID: params.Video.VideoSizeID}} | ||
sizeId := resolveVideoSizeId(thisImp.Video.Placement, thisImp.Instl) | ||
videoExt := rubiconVideoExt{Skip: params.Video.Skip, SkipDelay: params.Video.SkipDelay, RP: rubiconVideoExtRP{SizeID: sizeId}} | ||
thisImp.Video.Ext, err = json.Marshal(&videoExt) | ||
} else { | ||
primarySizeID, altSizeIDs, err := parseRubiconSizes(unit.Sizes) | ||
|
@@ -601,6 +602,22 @@ func (a *RubiconAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder * | |
return bids, nil | ||
} | ||
|
||
func resolveVideoSizeId(placement openrtb.VideoPlacementType, instl int8) (sizeID int) { | ||
if placement != 0 { | ||
if placement == 1 { | ||
return 201 | ||
} | ||
if placement == 3 { | ||
return 203 | ||
} | ||
} | ||
|
||
if instl == 1 { | ||
return 202 | ||
} | ||
return 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case an |
||
} | ||
|
||
func appendTrackerToUrl(uri string, tracker string) (res string) { | ||
// Append integration method. Adapter init happens once | ||
urlObject, err := url.Parse(uri) | ||
|
@@ -785,7 +802,8 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap | |
} | ||
|
||
videoCopy := *thisImp.Video | ||
videoExt := rubiconVideoExt{Skip: rubiconExt.Video.Skip, SkipDelay: rubiconExt.Video.SkipDelay, VideoType: videoType, RP: rubiconVideoExtRP{SizeID: rubiconExt.Video.VideoSizeID}} | ||
sizeId := resolveVideoSizeId(thisImp.Video.Placement, thisImp.Instl) | ||
videoExt := rubiconVideoExt{Skip: rubiconExt.Video.Skip, SkipDelay: rubiconExt.Video.SkipDelay, VideoType: videoType, RP: rubiconVideoExtRP{SizeID: sizeId}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that the
If future imps come with an empty |
||
videoCopy.Ext, err = json.Marshal(&videoExt) | ||
thisImp.Video = &videoCopy | ||
thisImp.Banner = nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,12 @@ type rubiAppendTrackerUrlTestScenario struct { | |
expected string | ||
} | ||
|
||
type rubiResolveVideoSizeIdTestScenario struct { | ||
placement openrtb.VideoPlacementType | ||
instl int8 | ||
expected int | ||
} | ||
|
||
type rubiTagInfo struct { | ||
code string | ||
zoneID int | ||
|
@@ -524,6 +530,36 @@ func TestAppendTracker(t *testing.T) { | |
} | ||
} | ||
|
||
func TestResolveVideoSizeId(t *testing.T) { | ||
testScenarios := []rubiResolveVideoSizeIdTestScenario{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can define the test struct right here as:
|
||
{ | ||
placement: 1, | ||
instl: 1, | ||
expected: 201, | ||
}, | ||
{ | ||
placement: 3, | ||
instl: 1, | ||
expected: 203, | ||
}, | ||
{ | ||
placement: 4, | ||
instl: 1, | ||
expected: 202, | ||
}, | ||
{ | ||
placement: 4, | ||
instl: 3, | ||
expected: 0, | ||
}, | ||
} | ||
|
||
for _, scenario := range testScenarios { | ||
res := resolveVideoSizeId(scenario.placement, scenario.instl) | ||
assert.Equal(t, scenario.expected, res) | ||
} | ||
} | ||
|
||
func TestNoContentResponse(t *testing.T) { | ||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
w.WriteHeader(http.StatusNoContent) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add JSON test cases to cover this part of the code as well where the
SizeID
is determined based onimp.Video.Placement