Skip to content

Commit

Permalink
Unit test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Veronika Solovei committed Apr 13, 2021
1 parent 27643cc commit be64bf0
Show file tree
Hide file tree
Showing 6 changed files with 288 additions and 31 deletions.
1 change: 1 addition & 0 deletions adapters/adapterstest/test_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func RunJSONBidderTest(t *testing.T, rootDir string, bidder adapters.Bidder) {
runTests(t, fmt.Sprintf("%s/supplemental", rootDir), bidder, true, false, false)
runTests(t, fmt.Sprintf("%s/amp", rootDir), bidder, true, true, false)
runTests(t, fmt.Sprintf("%s/video", rootDir), bidder, false, false, true)
runTests(t, fmt.Sprintf("%s/videosupplemental", rootDir), bidder, true, false, true)
}

// runTests runs all the *.json files in a directory. If allowErrors is false, and one of the test files
Expand Down
31 changes: 0 additions & 31 deletions adapters/appnexus/appnexus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,37 +205,6 @@ func TestVideoTwoPods(t *testing.T) {
assert.NotEqual(t, adPodId1, adPodId2, "AdPod id should be different for different pods")
}

func TestVideoTwoPodsDifferentAdPodId(t *testing.T) {
var a AppNexusAdapter
a.URI = "http://test.com/openrtb2"
a.hbSource = 5

var reqInfo adapters.ExtraRequestInfo
reqInfo.PbsEntryPoint = "video"

var req openrtb2.BidRequest
req.ID = "test_id"

reqExt := `{"prebid":{}}`
impExtPod1 := `{"bidder":{"placementId":123, "generate_ad_pod_id": true}}`
impExtPod2 := `{"bidder":{"placementId":123, "generate_ad_pod_id": false}}`
req.Ext = []byte(reqExt)

req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_0", Ext: []byte(impExtPod1)})
req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_1", Ext: []byte(impExtPod1)})
req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_2", Ext: []byte(impExtPod1)})

req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_0", Ext: []byte(impExtPod2)})
req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_1", Ext: []byte(impExtPod2)})
req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_2", Ext: []byte(impExtPod2)})

res, err := a.MakeRequests(&req, &reqInfo)

assert.Len(t, err, 1, "Errors array should not be empty")
assert.Equal(t, "generate ad pod option should be same for all pods in request", err[0].Error(), "Error is incorrect")
assert.Nil(t, res, "Result should be nil")
}

func TestVideoTwoPodsManyImps(t *testing.T) {
var a AppNexusAdapter
a.URI = "http://test.com/openrtb2"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1
}
}
},
{
"id": "2_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"uri": "http://ib.adnxs.com/openrtb2",
"body": {
"id": "test-request-id",
"ext": {
"appnexus": {
"hb_source": 6
},
"prebid": {}
},
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"appnexus": {
"placement_id": 1
}
}
},
{
"id": "2_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"appnexus": {
"placement_id": 1
}
}
}
]
}
},
"mockResponse": {
"status": 200,
"body": {}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": true
}
}
},
{
"id": "1_2",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": true
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"uri": "http://ib.adnxs.com/openrtb2",
"body": {
"id": "test-request-id",
"ext": {
"appnexus": {
"adpod_id": "5577006791947779410",
"hb_source": 6
},
"prebid": {}
},
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"appnexus": {
"placement_id": 1
}
}
},
{
"id": "1_2",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"appnexus": {
"placement_id": 1
}
}
}
]
}
},
"mockResponse": {
"status": 200,
"body": {}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": false
}
}
},
{
"id": "2_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": true
}
}
}
]
},

"expectedMakeRequestsErrors": [
{
"value": "generate ad pod option should be same for all pods in request",
"comparison": "literal"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": false
}
}
},
{
"id": "1_2",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": true
}
}
}
]
},

"expectedMakeRequestsErrors": [
{
"value": "generate ad pod option should be same for all pods in request",
"comparison": "literal"
}
]
}

0 comments on commit be64bf0

Please sign in to comment.