-
Notifications
You must be signed in to change notification settings - Fork 750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GumGum: Override the default currency #3928
GumGum: Override the default currency #3928
Conversation
Code coverage summaryNote:
gumgumRefer here for heat map coverage report
|
Code coverage summaryNote:
gumgumRefer here for heat map coverage report
|
@onkarvhanumante Could you please review? |
@minaguib @dlackty @dmitris @asweeney86 Could one of you please review? |
@hhhjort Could you please review this PR? |
@bsardo Could you please review this PR? |
adapters/gumgum/gumgum_test.go
Outdated
|
||
func TestResponseWithCurrencies(t *testing.T) { | ||
// Test for USD currency | ||
assertCurrencyInBidResponse(t, "USD", "USD") | ||
|
||
// Test for EUR currency | ||
assertCurrencyInBidResponse(t, "EUR", "EUR") | ||
} | ||
|
||
func assertCurrencyInBidResponse(t *testing.T, expectedCurrency string, currency string) { | ||
// Create a GumGum bidder | ||
bidder, buildErr := Builder(openrtb_ext.BidderGumGum, config.Adapter{ | ||
Endpoint: "https://g2.gumgum.com/providers/prbds2s/bid"}, config.Server{ | ||
ExternalUrl: "http://hosturl.com", | ||
GvlID: 1, | ||
DataCenter: "2", | ||
}) | ||
|
||
if buildErr != nil { | ||
t.Fatalf("Builder returned unexpected error %v", buildErr) | ||
} | ||
|
||
// Create a mock BidRequest | ||
prebidRequest := &openrtb2.BidRequest{ | ||
Imp: []openrtb2.Imp{}, | ||
} | ||
|
||
// Create a mock BidResponse with or without currency | ||
mockedBidResponse := &openrtb2.BidResponse{} | ||
if currency != "" { | ||
mockedBidResponse.Cur = currency | ||
} | ||
|
||
// Marshal the mock bid response to JSON | ||
body, err := json.Marshal(mockedBidResponse) | ||
if err != nil { | ||
t.Fatalf("Failed to marshal mock bid response: %v", err) | ||
} | ||
|
||
// Create a mock ResponseData | ||
responseData := &adapters.ResponseData{ | ||
StatusCode: 200, | ||
Body: body, | ||
} | ||
|
||
// Call MakeBids | ||
bidResponse, errs := bidder.MakeBids(prebidRequest, nil, responseData) | ||
|
||
// Assert no errors | ||
if len(errs) != 0 { | ||
t.Fatalf("Failed to make bids %v", errs) | ||
} | ||
|
||
// Assert that the currency is correctly set | ||
assert.Equal(t, expectedCurrency, bidResponse.Currency, "Expected currency to be set to "+expectedCurrency) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guidance is to test your adapter using the JSON test framework, in which case you can get rid of all of this and instead just copy your exemplary/banner.json
test into the supplemental
directory, rename it to convert-currency.json
and then just add "cur": "EUR"
to mockResponse.body
and "currency": "EUR"
to the object in the expectedBidResponses
array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bsardo I have addressed the above comment. Could you please review it? and thx for the review.
Code coverage summaryNote:
gumgumRefer here for heat map coverage report
|
…f github.com:MartinGumGum/prebid-server into ADTS-484-Set-bid-curency-in-Prebid-Server-GO-version
Code coverage summaryNote:
gumgumRefer here for heat map coverage report
|
@bsardo Could you please review this PR again? Thank you! |
This PR resolves an issue where bid currency from the Ad Exchange was not being set in the Prebid Server's Go version, causing the currency to default to USD in all cases. The bid currency will now be dynamically set based on the response from the Ad Exchange, ensuring proper handling of different currencies in the bidding process.