Skip to content

Commit

Permalink
Revert "OTT-55: Added empty function getBidDuration. Added unit tests…
Browse files Browse the repository at this point in the history
… with expectations around it"

This reverts commit 417f6fd.
  • Loading branch information
pm-shriprasad-marathe committed Dec 18, 2020
1 parent 417f6fd commit 40ebada
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 65 deletions.
20 changes: 0 additions & 20 deletions adapters/tagbidder/vast_tag_response_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,3 @@ func getPricingDetails(version string, ad *etree.Element) (float64, string, bool
var getRandomID = func() string {
return strconv.FormatInt(rand.Int63(), intBase)
}

// getBidDuration extracts the duration of the bid from ad element.
// The lookup may vary from vast version provided in the input
// returns duration in seconds or error if failed to obtained the duration
//
// The ad server uses the <Duration> element to denote
// the intended playback duration for the video or audio component of the ad.
// Time value may be in the format HH:MM:SS.mmm where .mmm indicates milliseconds.
// Providing milliseconds is optional.
//
// Reference
//
// 1.https://iabtechlab.com/wp-content/uploads/2019/06/VAST_4.2_final_june26.pdf
// 2.https://iabtechlab.com/wp-content/uploads/2018/11/VAST4.1-final-Nov-8-2018.pdf
// 3.https://iabtechlab.com/wp-content/uploads/2016/05/VAST4.0_Updated_April_2016.pdf
// 4.https://iabtechlab.com/wp-content/uploads/2016/04/VASTv3_0.pdf
func getBidDuration(version string, ad *etree.Element) (float32, error) {

return 0, nil
}
45 changes: 0 additions & 45 deletions adapters/tagbidder/vast_tag_response_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package tagbidder
import (
"testing"

"github.com/PubMatic-OpenWrap/etree"
"github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -77,47 +76,3 @@ func TestVASTTagResponseHandler_vastTagToBidderResponse(t *testing.T) {
})
}
}

func TestGetBidDuration(t *testing.T) {
type args struct {
version string // vast version
adEle *etree.Element // ad element
}
type want struct {
duration float32 // seconds (will converted from string with format as HH:MM:SS.mmm)
err string
}
tests := []struct {
name string
args args
want want
}{
{name: "no vast version", want: want{err: "Invalid vast version"}, args: args{version: ""}},
{name: "no ad element", want: want{err: "Invalid ad element"}, args: args{adEle: nil}},
{name: "invalid vast version", want: want{err: "Invalid vast version"}, args: args{version: "666666"}},
{name: "invalid ad element", want: want{err: "Invalid ad elementt"}, args: args{version: "2.0", adEle: etree.NewElement("some element")}},
// multiple ad elements
{name: "multiple ad elements", want: want{err: "multiple ad elements"}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>00:00:05/Duration> </Linear> </InLine> </Ad><Ad id="2"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>00.00.34</Duration> </Linear> </InLine> </Ad> `)}},
{name: "duration attrib not present", want: want{err: "duration is missing"}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> </Linear> </InLine> </Ad>`)}}, // mandatory as per https://iabtechlab.com/wp-content/uploads/2016/04/VAST-2_0-FINAL.pdf
{name: "duration attrib present", want: want{duration: 9}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>00:00:09</Duration> </Linear> </InLine> </Ad>`)}},
{name: "duration attrib all upper", want: want{duration: 50}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <DURATION>00:00:50</DURATION> </Linear> </InLine> </Ad>`)}},
{name: "duration 00:01:08 (1 min 8 seconds = 68 seconds)", want: want{duration: 68}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>00:01:08</Duration> </Linear> </InLine> </Ad>`)}},
{name: "duration 02:13:12 (2 hrs 13 min 12 seconds) = 7992 seconds)", want: want{duration: 7992}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>02:13:12</Duration> </Linear> </InLine> </Ad>`)}},
{name: "invalid duration 3:13:900 (3 hrs 13 min 900 seconds) = ?? )", want: want{err: "Invalid duration"}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>3:13:900</Duration> </Linear> </InLine> </Ad>`)}},
// 1 millsecond = 0.001 sec
// hence 45 seconds + 0.000038 seconds = 45.000038 seconds
{name: "duration = 0:0:45.038 , with milliseconds duration (0 hrs 0 min 45 seconds and 0.038 millseconds) = 45.000038 seconds )", want: want{duration: 45.000038}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>0:0:45.038</Duration> </Linear> </InLine>`)}},
{name: "duration = 56 (ambiguity w.r.t. HH:MM:SS.mmm format) ", want: want{err: "Invalid duration"}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>56</Duration> </Linear> </InLine> </Ad>`)}},
{name: "duration = :56 (ambiguity w.r.t. HH:MM:SS.mmm format) ", want: want{err: "Invalid duration"}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>:56</Duration> </Linear> </InLine> </Ad> `)}},
{name: "duration = :56: (ambiguity w.r.t. HH:MM:SS.mmm format) ", want: want{err: "Invalid duration"}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>:56:</Duration> </Linear> </InLine> </Ad>`)}},
{name: "duration = ::56 (ambiguity w.r.t. HH:MM:SS.mmm format) ", want: want{err: "Invalid duration"}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>::56</Duration> </Linear> </InLine> </Ad>`)}},
{name: "duration = 56.445 (ambiguity w.r.t. HH:MM:SS.mmm format) ", want: want{err: "Invalid duration"}, args: args{version: "2.0", adEle: etree.NewElement(`<Ad id="1"> <InLine> <Creatives> <Creative sequence="1"> <Linear> <Duration>56.445</Duration> </Linear> </InLine> </Ad> `)}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
dur, err := getBidDuration("", nil)
assert.Equal(t, tt.want.duration, dur)
assert.Equal(t, tt.want.err, err)
})
}
}

0 comments on commit 40ebada

Please sign in to comment.