diff --git a/adapters/tagbidder/vast_tag_response_handler.go b/adapters/tagbidder/vast_tag_response_handler.go index a598dba9f5a..79e1ed5a615 100644 --- a/adapters/tagbidder/vast_tag_response_handler.go +++ b/adapters/tagbidder/vast_tag_response_handler.go @@ -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 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 -} diff --git a/adapters/tagbidder/vast_tag_response_handler_test.go b/adapters/tagbidder/vast_tag_response_handler_test.go index 8306a0f7dfc..40dd0a18988 100644 --- a/adapters/tagbidder/vast_tag_response_handler_test.go +++ b/adapters/tagbidder/vast_tag_response_handler_test.go @@ -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" @@ -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(` 00:00:05/Duration> 00.00.34 `)}}, - {name: "duration attrib not present", want: want{err: "duration is missing"}, args: args{version: "2.0", adEle: etree.NewElement(` `)}}, // 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(` 00:00:09 `)}}, - {name: "duration attrib all upper", want: want{duration: 50}, args: args{version: "2.0", adEle: etree.NewElement(` 00:00:50 `)}}, - {name: "duration 00:01:08 (1 min 8 seconds = 68 seconds)", want: want{duration: 68}, args: args{version: "2.0", adEle: etree.NewElement(` 00:01:08 `)}}, - {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(` 02:13:12 `)}}, - {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(` 3:13:900 `)}}, - // 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(` 0:0:45.038 `)}}, - {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(` 56 `)}}, - {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(` :56 `)}}, - {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(` :56: `)}}, - {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(` ::56 `)}}, - {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(` 56.445 `)}}, - } - 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) - }) - } -}