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

Bugfix for missing fields in imp.video #1297

Merged
merged 3 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,10 @@ func max(a, b int) int {
}

func createImpressionTemplate(imp openrtb.Imp, video *openrtb.Video) openrtb.Imp {
imp.Video = &openrtb.Video{}
imp.Video.W = video.W
imp.Video.H = video.H
imp.Video.Protocols = video.Protocols
imp.Video.MIMEs = video.MIMEs
//for every new impression we need to have it's own copy of video object, because we customize it in further processing
newVideo := &openrtb.Video{}
SyntaxNode marked this conversation as resolved.
Show resolved Hide resolved
*newVideo = *video
imp.Video = newVideo
return imp
}

Expand Down
25 changes: 25 additions & 0 deletions endpoints/openrtb2/video_auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,31 @@ func TestHandleErrorDebugLog(t *testing.T) {
assert.NotEmpty(t, debugLog.CacheKey, "DebugLog CacheKey value should have been set")
}

func TestCreateImpressionTemplate(t *testing.T) {

imp := openrtb.Imp{}
imp.Video = &openrtb.Video{}
imp.Video.Protocols = []openrtb.Protocol{1, 2}
imp.Video.MIMEs = []string{"video/mp4"}
imp.Video.H = 200
imp.Video.W = 400
imp.Video.PlaybackMethod = []openrtb.PlaybackMethod{5, 6}

video := openrtb.Video{}
video.Protocols = []openrtb.Protocol{3, 4}
video.MIMEs = []string{"video/flv"}
video.H = 300
video.W = 0
video.PlaybackMethod = []openrtb.PlaybackMethod{7, 8}

res := createImpressionTemplate(imp, &video)
assert.Equal(t, res.Video.Protocols, []openrtb.Protocol{3, 4}, "")
assert.Equal(t, res.Video.MIMEs, []string{"video/flv"}, "")
assert.Equal(t, int(res.Video.H), 300, "")
assert.Equal(t, int(res.Video.W), 0, "")
assert.Equal(t, res.Video.PlaybackMethod, []openrtb.PlaybackMethod{7, 8}, "")
}

func mockDepsWithMetrics(t *testing.T, ex *mockExchangeVideo) (*endpointDeps, *pbsmetrics.Metrics, *mockAnalyticsModule) {
theMetrics := pbsmetrics.NewMetrics(metrics.NewRegistry(), openrtb_ext.BidderList(), config.DisabledMetrics{})
mockModule := &mockAnalyticsModule{}
Expand Down