Skip to content

Commit

Permalink
Updating exchange unit tests to remove extra bids
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Rice committed Nov 1, 2019
1 parent 3df0227 commit a23dfb2
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions exchange/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,22 +753,18 @@ func TestCategoryMappingTranslateCategoriesNil(t *testing.T) {
cats1 := []string{"IAB1-3"}
cats2 := []string{"IAB1-4"}
cats3 := []string{"IAB1-1000"}
cats4 := []string{"IAB1-2000"}
bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1}
bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1}
bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1}
bid4 := openrtb.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 40.0000, Cat: cats4, W: 1, H: 1}

bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}}
bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}}
bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30, PrimaryCategory: "AdapterOverride"}}
bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}}
bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}}

innerBids := []*pbsOrtbBid{
&bid1_1,
&bid1_2,
&bid1_3,
&bid1_4,
}

seatBid := pbsOrtbSeatBid{innerBids, "USD", nil, nil}
Expand All @@ -781,9 +777,8 @@ func TestCategoryMappingTranslateCategoriesNil(t *testing.T) {
assert.Equal(t, nil, err, "Category mapping error should be empty")
assert.Equal(t, "10.00_Electronics_30s", bidCategory["bid_id1"], "Category mapping doesn't match")
assert.Equal(t, "20.00_Sports_50s", bidCategory["bid_id2"], "Category mapping doesn't match")
assert.Equal(t, "20.00_AdapterOverride_30s", bidCategory["bid_id3"], "Category mapping override from adapter didn't take")
assert.Equal(t, 3, len(adapterBids[bidderName1].bids), "Bidders number doesn't match")
assert.Equal(t, 3, len(bidCategory), "Bidders category mapping doesn't match")
assert.Equal(t, 2, len(adapterBids[bidderName1].bids), "Bidders number doesn't match")
assert.Equal(t, 2, len(bidCategory), "Bidders category mapping doesn't match")
}

func TestCategoryMappingTranslateCategoriesFalse(t *testing.T) {
Expand All @@ -807,22 +802,18 @@ func TestCategoryMappingTranslateCategoriesFalse(t *testing.T) {
cats1 := []string{"IAB1-3"}
cats2 := []string{"IAB1-4"}
cats3 := []string{"IAB1-1000"}
cats4 := []string{"IAB1-2000"}
bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1}
bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1}
bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1}
bid4 := openrtb.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 40.0000, Cat: cats4, W: 1, H: 1}

bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}}
bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}}
bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30, PrimaryCategory: "AdapterOverride"}}
bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}}
bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}}

innerBids := []*pbsOrtbBid{
&bid1_1,
&bid1_2,
&bid1_3,
&bid1_4,
}

seatBid := pbsOrtbSeatBid{innerBids, "USD", nil, nil}
Expand All @@ -835,10 +826,9 @@ func TestCategoryMappingTranslateCategoriesFalse(t *testing.T) {
assert.Equal(t, nil, err, "Category mapping error should be empty")
assert.Equal(t, "10.00_IAB1-3_30s", bidCategory["bid_id1"], "Category should not be translated")
assert.Equal(t, "20.00_IAB1-4_50s", bidCategory["bid_id2"], "Category should not be translated")
assert.Equal(t, "20.00_AdapterOverride_30s", bidCategory["bid_id3"], "Category mapping override from adapter didn't take")
assert.Equal(t, "20.00_IAB1-2000_30s", bidCategory["bid_id4"], "Bid should not be rejected")
assert.Equal(t, 4, len(adapterBids[bidderName1].bids), "Bidders number doesn't match")
assert.Equal(t, 4, len(bidCategory), "Bidders category mapping doesn't match")
assert.Equal(t, "20.00_IAB1-1000_30s", bidCategory["bid_id3"], "Bid should not be rejected")
assert.Equal(t, 3, len(adapterBids[bidderName1].bids), "Bidders number doesn't match")
assert.Equal(t, 3, len(bidCategory), "Bidders category mapping doesn't match")
}

func TestCategoryDedupe(t *testing.T) {
Expand Down

0 comments on commit a23dfb2

Please sign in to comment.