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

Added more unit tests #1

Merged
merged 1 commit into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 15 additions & 7 deletions adapters/33across/33across.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Request
errs = append(errs, err)
}

if reqCopy.Imp[0].Banner == nil && reqCopy.Imp[0].Video == nil {
errs = append(errs, &errortypes.BadInput{
Message: "At least one of [banner, video] formats must be defined in Imp. None found",
})

return nil, errs
}

// Last Step
reqJSON, err := json.Marshal(reqCopy)
if err != nil {
Expand Down Expand Up @@ -106,24 +114,24 @@ func preprocess(request *openrtb.BidRequest) error {
}
}

imp.Ext = impExtJSON
siteCopy := *request.Site
siteCopy.ID = ttxExt.SiteId
request.Site = &siteCopy

// Validate Video if it exists
if imp.Video != nil {
videoCopy, err := validateVideoParams(imp.Video, impExt.Ttx.Prod)

imp.Video = videoCopy

if err != nil {
return &errortypes.BadInput{
Message: err.Error(),
}
}

imp.Video = videoCopy
}

imp.Ext = impExtJSON
siteCopy := *request.Site
siteCopy.ID = ttxExt.SiteId
request.Site = &siteCopy

return nil
}

Expand Down
100 changes: 100 additions & 0 deletions adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"video": {
"w": 728,
"h": 90,
"protocols": [2],
"placement": 1,
"startdelay": -2,
"playbackmethod": [2],
"mimes": ["foo", "bar"]
},
"ext": {
"bidder": {
"siteId": "fake-site-id",
"productId": "instream"
}
}
}
],
"site": {}
},

"httpCalls": [
{
"expectedRequest": {
"uri": "http://ssc.33across.com",
"body": {
"id": "test-request-id",
"imp": [
{
"id":"test-imp-id",
"video": {
"w": 728,
"h": 90,
"protocols": [2],
"placement": 1,
"startdelay": -2,
"playbackmethod": [2],
"mimes": ["foo", "bar"]
},
"ext": {
"ttx": {
"prod": "instream"
}
}
}
],
"site": {
"id": "fake-site-id"
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "ttx",
"bid": [{
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.500000,
"adm": "some-test-vast-ad",
"crid": "crid_10",
"h": 90,
"w": 728
}]
}
],
"cur": "USD"
}
}
}
],

"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.5,
"adm": "some-test-vast-ad",
"crid": "crid_10",
"w": 728,
"h": 90
},
"type": "banner"
}
]
}
]
}
108 changes: 108 additions & 0 deletions adapters/33across/33acrosstest/exemplary/instream-video-defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"video": {
"w": 728,
"h": 90,
"protocols": [2],
"playbackmethod": [2],
"mimes": ["foo", "bar"]
},
"ext": {
"bidder": {
"siteId": "fake-site-id",
"productId": "instream"
}
}
}
],
"site": {}
},

"httpCalls": [
{
"expectedRequest": {
"uri": "http://ssc.33across.com",
"body": {
"id": "test-request-id",
"imp": [
{
"id":"test-imp-id",
"video": {
"w": 728,
"h": 90,
"protocols": [2],
"placement": 1,
"startdelay": 0,
"playbackmethod": [2],
"mimes": ["foo", "bar"]
},
"ext": {
"ttx": {
"prod": "instream"
}
}
}
],
"site": {
"id": "fake-site-id"
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "ttx",
"bid": [{
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.500000,
"adm": "some-test-vast-ad",
"crid": "crid_10",
"h": 90,
"w": 728,
"ext": {
"ttx": {
"mediaType": "video"
}
}
}]
}
],
"cur": "USD"
}
}
}
],

"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.5,
"adm": "some-test-vast-ad",
"crid": "crid_10",
"w": 728,
"h": 90,
"ext": {
"ttx": {
"mediaType": "video"
}
}
},
"type": "video"
}
]
}
]
}
107 changes: 107 additions & 0 deletions adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"video": {
"w": 728,
"h": 90,
"protocols": [2],
"playbackmethod": [2],
"mimes": ["foo", "bar"]
},
"ext": {
"bidder": {
"siteId": "fake-site-id",
"productId": "siab"
}
}
}
],
"site": {}
},

"httpCalls": [
{
"expectedRequest": {
"uri": "http://ssc.33across.com",
"body": {
"id": "test-request-id",
"imp": [
{
"id":"test-imp-id",
"video": {
"w": 728,
"h": 90,
"protocols": [2],
"placement": 2,
"playbackmethod": [2],
"mimes": ["foo", "bar"]
},
"ext": {
"ttx": {
"prod": "siab"
}
}
}
],
"site": {
"id": "fake-site-id"
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "ttx",
"bid": [{
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.500000,
"adm": "some-test-vast-ad",
"crid": "crid_10",
"h": 90,
"w": 728,
"ext": {
"ttx": {
"mediaType": "video"
}
}
}]
}
],
"cur": "USD"
}
}
}
],

"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.5,
"adm": "some-test-vast-ad",
"crid": "crid_10",
"w": 728,
"h": 90,
"ext": {
"ttx": {
"mediaType": "video"
}
}
},
"type": "video"
}
]
}
]
}
14 changes: 12 additions & 2 deletions adapters/33across/33acrosstest/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
"adm": "some-test-ad",
"crid": "crid_10",
"h": 90,
"w": 728
"w": 728,
"ext": {
"ttx": {
"mediaType": "banner"
}
}
}]
}
],
Expand All @@ -78,7 +83,12 @@
"adm": "some-test-ad",
"crid": "crid_10",
"w": 728,
"h": 90
"h": 90,
"ext": {
"ttx": {
"mediaType": "banner"
}
}
},
"type": "banner"
}
Expand Down
Loading