Skip to content

Commit

Permalink
Mansi's feedback in regards of file and directory naming and addition…
Browse files Browse the repository at this point in the history
…al test cases
  • Loading branch information
Gus Carreon authored and Gus Carreon committed Jun 9, 2021
1 parent 32a3a22 commit c9ee8e1
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 2 deletions.
12 changes: 10 additions & 2 deletions endpoints/openrtb2/auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,21 @@ func TestJsonSampleRequests(t *testing.T) {
"Requests with first party data context info found in imp[i].ext.prebid.bidder,context",
"first-party-data",
},
{
"Assert we correctly use the server conversion rates when needed",
"currency-conversion/server-rates/valid",
},
{
"Assert we correctly throw an error when no conversion rate was found in the server conversions map",
"currency-conversion/server-rates/errors",
},
{
"Assert we correctly use request-defined custom currency rates when present in root.ext",
"custom-currency/valid",
"currency-conversion/custom-rates/valid",
},
{
"Assert we correctly validate request-defined custom currency rates when present in root.ext",
"custom-currency/errors",
"currency-conversion/custom-rates/errors",
},
}
for _, test := range testSuites {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"description": "currency in request.cur cannot be converted because conversion rate not found in either custom currency rates nor server rates. usepbsrates defaults to true",
"config": {
"currencyRates":{
"USD": {
"MXN": 2.00
}
},
"mockBidder": {
"currency": "USD",
"price": 1.00
}
},
"mockBidRequest": {
"id": "some-request-id",
"site": {
"page": "test.somepage.com"
},
"imp": [
{
"id": "my-imp-id",
"video": {
"mimes": [
"video/mp4"
]
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
],
"cur": ["GBP"],
"ext": {
"prebid": {
"aliases": {
"unknown": "appnexus"
},
"currency": {
"rates": {
"USD": {
"MXN": 5.00
}
}
}
}
}
},
"expectedReturnCode": 500,
"expectedErrorMessage": "Critical error while running the auction: Can't produce bid with no valid currency to use or currency conversion to convert to."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"description": "Despite being more expensive, custom conversion rate overrides that of the currency conversion service. usepbsrates was true",
"config": {
"currencyRates":{
"USD": {
"MXN": 2.00
}
},
"mockBidder": {
"currency": "USD",
"price": 1.00
}
},
"mockBidRequest": {
"id": "some-request-id",
"site": {
"page": "test.somepage.com"
},
"imp": [
{
"id": "my-imp-id",
"video": {
"mimes": [
"video/mp4"
]
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
],
"cur": ["MXN"],
"ext": {
"prebid": {
"aliases": {
"unknown": "appnexus"
},
"currency": {
"rates": {
"USD": {
"CAD": 5.00
}
},
"usepbsrates": true
}
}
}
},
"expectedBidResponse": {
"id":"some-request-id",
"bidid":"test bid id",
"cur": "MXN",
"nbr":0,
"seatbid": [
{
"bid": [
{
"id": "appnexus-bid",
"impid": "",
"price": 2.00
}
],
"seat": "appnexus-bids"
}
]
},
"expectedReturnCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"description": "bid request calls for a bid in foreign currency MXN but conversion rate is not found in the currency conversion service.",
"config": {
"currencyRates":{
"USD": {
"GBP": 0.80
}
},
"mockBidder": {
"currency": "USD",
"price": 1.00
}
},
"mockBidRequest": {
"id": "some-request-id",
"site": {
"page": "test.somepage.com"
},
"cur": ["MXN"],
"imp": [
{
"id": "my-imp-id",
"video": {
"mimes": [
"video/mp4"
]
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
]
},
"expectedReturnCode": 500,
"expectedErrorMessage": "Critical error while running the auction: Can't produce bid with no valid currency to use or currency conversion to convert to."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"description": "bid request calls for a bid in foreign currency but mockbidder bids in USD. Conversion rate is applied",
"config": {
"currencyRates":{
"USD": {
"MXN": 2.00
}
},
"mockBidder": {
"currency": "USD",
"price": 1.00
}
},
"mockBidRequest": {
"id": "some-request-id",
"site": {
"page": "test.somepage.com"
},
"cur": ["MXN"],
"imp": [
{
"id": "my-imp-id",
"video": {
"mimes": [
"video/mp4"
]
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
]
},
"expectedBidResponse": {
"id":"some-request-id",
"bidid":"test bid id",
"cur": "MXN",
"nbr":0,
"seatbid": [
{
"bid": [
{
"id": "appnexus-bid",
"impid": "",
"price": 2.00
}
],
"seat": "appnexus-bids"
}
]
},
"expectedReturnCode": 200
}

0 comments on commit c9ee8e1

Please sign in to comment.