Skip to content

Commit

Permalink
Merge pull request #1 from 33Across/add_test_coverage
Browse files Browse the repository at this point in the history
Added more unit tests
  • Loading branch information
curlyblueeagle authored Nov 6, 2020
2 parents e248833 + 820fb30 commit 193c42f
Show file tree
Hide file tree
Showing 7 changed files with 441 additions and 9 deletions.
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

0 comments on commit 193c42f

Please sign in to comment.