Skip to content

Commit

Permalink
Address multiple comments about test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-gielow-ttd committed Aug 1, 2024
1 parent 1474c4d commit 66b9177
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 373 deletions.
8 changes: 6 additions & 2 deletions adapters/thetradedesk/thetradedesk.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E
siteCopy := *request.Site
if siteCopy.Publisher != nil {
publisherCopy := *siteCopy.Publisher
publisherCopy.ID = pubID
if pubID != "" {
publisherCopy.ID = pubID
}
siteCopy.Publisher = &publisherCopy
} else {
siteCopy.Publisher = &openrtb2.Publisher{ID: pubID}
Expand All @@ -67,7 +69,9 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E
appCopy := *request.App
if appCopy.Publisher != nil {
publisherCopy := *appCopy.Publisher
publisherCopy.ID = pubID
if pubID != "" {
publisherCopy.ID = pubID
}
appCopy.Publisher = &publisherCopy
} else {
appCopy.Publisher = &openrtb2.Publisher{ID: pubID}
Expand Down
34 changes: 17 additions & 17 deletions adapters/thetradedesk/thetradedesk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,31 @@ func TestGetBidType(t *testing.T) {
wantErr bool
}{
{
name: "getBidType banner",
name: "banner",
args: args{
markupType: openrtb2.MarkupBanner,
},
expectedBidTypeId: openrtb_ext.BidTypeBanner,
wantErr: false,
},
{
name: "getBidType video",
name: "video",
args: args{
markupType: openrtb2.MarkupVideo,
},
expectedBidTypeId: openrtb_ext.BidTypeVideo,
wantErr: false,
},
{
name: "getBidType native",
name: "native",
args: args{
markupType: openrtb2.MarkupNative,
},
expectedBidTypeId: openrtb_ext.BidTypeNative,
wantErr: false,
},
{
name: "getBidType invalid",
name: "invalid",
args: args{
markupType: -1,
},
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestGetPublisherId(t *testing.T) {
wantErr bool
}{
{
name: "valid publisher Id",
name: "valid_publisher_Id",
args: args{
impressions: []openrtb2.Imp{
{
Expand All @@ -140,7 +140,7 @@ func TestGetPublisherId(t *testing.T) {
wantErr: false,
},
{
name: "multiple valid publisher Id",
name: "multiple_valid_publisher_Id",
args: args{
impressions: []openrtb2.Imp{
{
Expand All @@ -157,7 +157,7 @@ func TestGetPublisherId(t *testing.T) {
wantErr: false,
},
{
name: "not publisherId present",
name: "not_publisherId_present",
args: args{
impressions: []openrtb2.Imp{
{
Expand All @@ -170,7 +170,7 @@ func TestGetPublisherId(t *testing.T) {
wantErr: false,
},
{
name: "nil publisherId present",
name: "nil_publisherId_present",
args: args{
impressions: []openrtb2.Imp{
{
Expand All @@ -183,15 +183,15 @@ func TestGetPublisherId(t *testing.T) {
wantErr: false,
},
{
name: "no impressions",
name: "no_impressions",
args: args{
impressions: []openrtb2.Imp{},
},
expectedPublisherId: "",
wantErr: false,
},
{
name: "invalid bidder object",
name: "invalid_bidder_object",
args: args{
impressions: []openrtb2.Imp{
{
Expand Down Expand Up @@ -229,14 +229,14 @@ func TestTheTradeDeskAdapter_MakeRequests(t *testing.T) {
wantErr bool
}{
{
name: "invalid bidderparams",
name: "invalid_bidderparams",
args: args{
request: &openrtb2.BidRequest{Ext: json.RawMessage(`{"prebid":{"bidderparams":{:"123"}}}`)},
},
wantErr: true,
},
{
name: "request with App",
name: "request_with_App",
args: args{
request: &openrtb2.BidRequest{
App: &openrtb2.App{},
Expand All @@ -246,7 +246,7 @@ func TestTheTradeDeskAdapter_MakeRequests(t *testing.T) {
wantErr: false,
},
{
name: "request with App and publisher",
name: "request_with_App_and_publisher",
args: args{
request: &openrtb2.BidRequest{
App: &openrtb2.App{Publisher: &openrtb2.Publisher{}},
Expand All @@ -256,7 +256,7 @@ func TestTheTradeDeskAdapter_MakeRequests(t *testing.T) {
wantErr: false,
},
{
name: "request with Site",
name: "request_with_Site",
args: args{
request: &openrtb2.BidRequest{
Site: &openrtb2.Site{},
Expand Down Expand Up @@ -297,7 +297,7 @@ func TestTheTradeDeskAdapter_MakeBids(t *testing.T) {
wantResp *adapters.BidderResponse
}{
{
name: "happy path, valid response with all bid params",
name: "happy_path_valid_response_with_all_bid_params",
args: args{
response: &adapters.ResponseData{
StatusCode: http.StatusOK,
Expand Down Expand Up @@ -329,7 +329,7 @@ func TestTheTradeDeskAdapter_MakeBids(t *testing.T) {
},
},
{
name: "ignore invalid prebiddealpriority",
name: "ignore_invalid_prebiddealpriority",
args: args{
response: &adapters.ResponseData{
StatusCode: http.StatusOK,
Expand Down Expand Up @@ -361,7 +361,7 @@ func TestTheTradeDeskAdapter_MakeBids(t *testing.T) {
},
},
{
name: "no content response",
name: "no_content_response",
args: args{
response: &adapters.ResponseData{
StatusCode: http.StatusNoContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"h": 250
}
],
"w": 300,
"h": 250
"w": 100,
"h": 150
},
"ext": {
"bidder": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@
"ip": "91.199.242.236",
"ua": "random user agent"
},
"user": {
"ext": {
"eids": [
{
"source": "ttd.com",
"uids": [
{
"id": "ttd-uid"
}
]
}
]
}
},
"imp": [
{
"id": "test-imp-id",
Expand All @@ -41,8 +27,8 @@
"h": 300
}
],
"w": 100,
"h": 150
"w": 55,
"h": 33
},
"ext": {
"bidder": {
Expand All @@ -55,16 +41,16 @@
"banner": {
"format": [
{
"w": 300,
"h": 250
"w": 900,
"h": 450
},
{
"w": 500,
"h": 300
}
],
"w": 100,
"h": 150
"w": 88,
"h": 99
},
"ext": {
"bidder": {
Expand Down Expand Up @@ -101,20 +87,6 @@
"ip": "91.199.242.236",
"ua": "random user agent"
},
"user": {
"ext": {
"eids": [
{
"source": "ttd.com",
"uids": [
{
"id": "ttd-uid"
}
]
}
]
}
},
"imp": [
{
"id": "test-imp-id",
Expand Down Expand Up @@ -143,16 +115,16 @@
"banner": {
"format": [
{
"w": 300,
"h": 250
"w": 900,
"h": 450
},
{
"w": 500,
"h": 300
}
],
"w": 300,
"h": 250
"w": 900,
"h": 450
},
"ext": {
"bidder": {
Expand Down Expand Up @@ -196,8 +168,8 @@
"price": 0.5,
"crid": "creative-123",
"adm": "<iframe id='789abc' name='789abc' src='http://creative-url.ttd.com'></iframe>",
"w": 300,
"h": 250,
"w": 900,
"h": 450,
"ext": {
"prebid": {
"type": "banner"
Expand Down Expand Up @@ -241,8 +213,8 @@
"price": 0.5,
"crid": "creative-123",
"adm": "<iframe id='789abc' name='789abc' src='http://creative-url.ttd.com'></iframe>",
"w": 300,
"h": 250,
"w": 900,
"h": 450,
"ext": {
"prebid": {
"type": "banner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@
"ip": "91.199.242.236",
"ua": "random user agent"
},
"user": {
"ext": {
"eids": [
{
"source": "ttd.com",
"uids": [
{
"id": "ttd-uid"
}
]
}
]
}
},
"imp": [
{
"id": "test-imp-id",
Expand Down Expand Up @@ -93,20 +79,6 @@
"ip": "91.199.242.236",
"ua": "random user agent"
},
"user": {
"ext": {
"eids": [
{
"source": "ttd.com",
"uids": [
{
"id": "ttd-uid"
}
]
}
]
}
},
"imp": [
{
"id": "test-imp-id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"id": "test-request-id",
"site": {
"id": "site-id",
"page": "ttd.com"
"page": "ttd.com",
"publisher": {
"id": "123456"
}
},
"device": {
"os": "android",
"ip": "91.199.242.236",
"ua": "random user agent"
},
"user": {
"buyeruid": "ttd-user-id"
},
"imp": [
{
"id": "test-imp-id",
Expand All @@ -23,8 +23,8 @@
"h": 250
}
],
"w": 300,
"h": 250
"w": 100,
"h": 150
},
"ext": {
"bidder": {
Expand Down Expand Up @@ -61,9 +61,6 @@
"ip": "91.199.242.236",
"ua": "random user agent"
},
"user": {
"buyeruid": "ttd-user-id"
},
"imp": [
{
"id": "test-imp-id",
Expand All @@ -90,7 +87,6 @@
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"currency": "USD",
"seatbid": [
{
Expand Down
Loading

0 comments on commit 66b9177

Please sign in to comment.