Skip to content

Commit

Permalink
add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
junping.zhao committed May 8, 2020
1 parent 59d226d commit 0558b6e
Show file tree
Hide file tree
Showing 9 changed files with 433 additions and 5 deletions.
7 changes: 2 additions & 5 deletions adapters/yeahmobi/yeahmobi.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,15 @@ func (adapter *YeahmobiAdapter) makeRequest(request *openrtb.BidRequest) (*adapt
glog.Fatal("Invalid ExtImpYeahmobi value")
return nil, errs
}

endPoint, err := adapter.getEndpoint(yeahmobiExt)

transform(request)

if err != nil {
return nil, append(errs, err)
}
transform(request)
reqBody, err := json.Marshal(request)

if err != nil {
errs = append(errs, err)
return nil, append(errs, err)
}

headers := http.Header{}
Expand Down
51 changes: 51 additions & 0 deletions adapters/yeahmobi/yeahmobitest/exemplary/no-bid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [{"w": 300, "h": 50}]
},
"ext": {
"bidder": {
"pubId": "fake-pub-id",
"zoneId": "sin"
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://gw-sin-bid.yeahtargeter.com/prebid/bid",
"body": {
"id": "test-request-id",
"imp": [
{
"id":"test-imp-id",
"banner": {
"format": [{"w": 300, "h": 50}]
},
"ext": {
"bidder": {
"pubId": "fake-pub-id",
"zoneId": "sin"
}
}
}
]
}
},
"mockResponse": {
"status": 204,
"body": {}
}
}
],

"expectedBidResponses": []

}
82 changes: 82 additions & 0 deletions adapters/yeahmobi/yeahmobitest/exemplary/simple-native-1.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"native": {
"request": "{\"native\":{\"ver\":\"1.2\",\"context\":1,\"plcmttype\":4,\"plcmtcnt\":1,\"assets\":[{\"id\":2,\"required\":1,\"title\":{\"len\":90}},{\"id\":6,\"required\":1,\"img\":{\"type\":3,\"wmin\":128,\"hmin\":128,\"mimes\":[\"image/jpg\",\"image/jpeg\",\"image/png\"]}},{\"id\":7,\"required\":1,\"data\":{\"type\":2,\"len\":120}}]}}",
"ver": "1.2"
},
"ext": {
"bidder": {
"pubId": "fake-pub-id",
"zoneId": "sin"
}
}
}
]
},
"httpcalls": [
{
"expectedRequest": {
"uri": "https://gw-sin-bid.yeahtargeter.com/prebid/bid",
"body": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"native": {
"request": "{\"native\":{\"ver\":\"1.2\",\"context\":1,\"plcmttype\":4,\"plcmtcnt\":1,\"assets\":[{\"id\":2,\"required\":1,\"title\":{\"len\":90}},{\"id\":6,\"required\":1,\"img\":{\"type\":3,\"wmin\":128,\"hmin\":128,\"mimes\":[\"image/jpg\",\"image/jpeg\",\"image/png\"]}},{\"id\":7,\"required\":1,\"data\":{\"type\":2,\"len\":120}}]}}",
"ver": "1.2"
},
"ext": {
"bidder": {
"pubId": "fake-pub-id",
"zoneId": "sin"
}
}
}
]
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"bid": [
{
"id": "8400d766-58b3-47d4-80d7-6658b337d403",
"impid": "test-imp-id",
"price": 1.2,
"adm": "some ads",
"crid": "crid_testid"
}
]
}
]
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "8400d766-58b3-47d4-80d7-6658b337d403",
"impid": "test-imp-id",
"price": 1.2,
"adm": "some ads",
"crid": "crid_testid"

},
"type": "native"
}
]
}
]
}
89 changes: 89 additions & 0 deletions adapters/yeahmobi/yeahmobitest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"video": {
"w": 300,
"h": 250,
"mimes": [
"video/mp4"
]
},
"ext": {
"bidder": {
"pubId": "fake-pub-id",
"zoneId": "sin"
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://gw-sin-bid.yeahtargeter.com/prebid/bid",
"body": {
"id": "test-request-id",
"imp": [
{
"id":"test-imp-id",
"video": {
"w": 300,
"h": 250,
"mimes": [
"video/mp4"
]
},
"ext": {
"bidder": {
"pubId": "fake-pub-id",
"zoneId": "sin"
}
}
}
]
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "ttx",
"bid": [{
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 1.2,
"adm": "some-ads",
"crid": "crid_testid"
}]
}
],
"cur": "USD"
}
}
}
],

"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 1.2,
"adm": "some-ads",
"crid": "crid_testid"
},
"type": "video"
}
]
}
]
}
21 changes: 21 additions & 0 deletions adapters/yeahmobi/yeahmobitest/supplemental/bad_imp_ext.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [{"w": 300, "h": 50}]
},
"ext": "aaa"
}
]
},

"expectedMakeRequestsErrors": [
{
"value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder",
"comparison": "literal"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [{"w": 300, "h": 50}]
},
"ext": {
"bidder": "aa"
}
}
]
},

"expectedMakeRequestsErrors": [
{
"value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpYeahmobi",
"comparison": "literal"
}
]
}
55 changes: 55 additions & 0 deletions adapters/yeahmobi/yeahmobitest/supplemental/bad_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [{"w": 300, "h": 50}]
},
"ext": {
"bidder": {
"pubId": "fake-pub-id",
"zoneId": "sin"
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://gw-sin-bid.yeahtargeter.com/prebid/bid",
"body": {
"id": "test-request-id",
"imp": [
{
"id":"test-imp-id",
"banner": {
"format": [{"w": 300, "h": 50}]
},
"ext": {
"bidder": {
"pubId": "fake-pub-id",
"zoneId": "sin"
}
}
}
]
}
},
"mockResponse": {
"status": 200,
"body": "{\"id\":test-request-id"
}
}
],

"expectedMakeBidsErrors": [
{
"comparison": "literal",
"value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse"
}
]
}
Loading

0 comments on commit 0558b6e

Please sign in to comment.