-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openx adapter: forward bid response currency in openx adapter if set
it was always set to the default USD before
- Loading branch information
1 parent
2e80651
commit f6d8a14
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,48 @@ | ||
package openx | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/mxmCherry/openrtb" | ||
"github.com/prebid/prebid-server/adapters" | ||
"github.com/prebid/prebid-server/adapters/adapterstest" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestJsonSamples(t *testing.T) { | ||
adapterstest.RunJSONBidderTest(t, "openxtest", NewOpenxBidder("http://rtb.openx.net/prebid")) | ||
} | ||
|
||
func TestResponseWithCurrencies(t *testing.T) { | ||
assertCurrencyInBidResponse(t, "USD", nil) | ||
|
||
currency := "USD" | ||
assertCurrencyInBidResponse(t, "USD", ¤cy) | ||
|
||
currency = "EUR" | ||
assertCurrencyInBidResponse(t, "EUR", ¤cy) | ||
} | ||
|
||
func assertCurrencyInBidResponse(t *testing.T, expectedCurrency string, currency *string) { | ||
|
||
bidder := NewOpenxBidder("http://rtb.openx.net/prebid") | ||
prebidRequest := &openrtb.BidRequest{ | ||
Imp: []openrtb.Imp{}, | ||
} | ||
mockedBidResponse := &openrtb.BidResponse{} | ||
if currency != nil { | ||
mockedBidResponse.Cur = *currency | ||
} | ||
body, _ := json.Marshal(mockedBidResponse) | ||
responseData := &adapters.ResponseData{ | ||
StatusCode: 200, | ||
Body: body, | ||
} | ||
bidResponse, errs := bidder.MakeBids(prebidRequest, nil, responseData) | ||
|
||
if errs != nil { | ||
t.Fatalf("Failed to make bids %v", errs) | ||
} | ||
assert.Equal(t, expectedCurrency, bidResponse.Currency) | ||
} |