Skip to content

Commit

Permalink
Bugfix for missing fields in imp.video (#1297)
Browse files Browse the repository at this point in the history
Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>
  • Loading branch information
VeronikaSolovei9 and Veronika Solovei authored May 14, 2020
1 parent 93b8a0e commit c18a2d8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
8 changes: 3 additions & 5 deletions endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,9 @@ 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 := *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}, "Incorrect video protocols")
assert.Equal(t, res.Video.MIMEs, []string{"video/flv"}, "Incorrect video MIMEs")
assert.Equal(t, int(res.Video.H), 300, "Incorrect video height")
assert.Equal(t, int(res.Video.W), 0, "Incorrect video width")
assert.Equal(t, res.Video.PlaybackMethod, []openrtb.PlaybackMethod{7, 8}, "Incorrect video playback method")
}

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

0 comments on commit c18a2d8

Please sign in to comment.