Skip to content

Commit c9ee8e1

Browse files
Gus CarreonGus Carreon
Gus Carreon
authored and
Gus Carreon
committed
Mansi's feedback in regards of file and directory naming and additional test cases
1 parent 32a3a22 commit c9ee8e1

15 files changed

+225
-2
lines changed

endpoints/openrtb2/auction_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,21 @@ func TestJsonSampleRequests(t *testing.T) {
108108
"Requests with first party data context info found in imp[i].ext.prebid.bidder,context",
109109
"first-party-data",
110110
},
111+
{
112+
"Assert we correctly use the server conversion rates when needed",
113+
"currency-conversion/server-rates/valid",
114+
},
115+
{
116+
"Assert we correctly throw an error when no conversion rate was found in the server conversions map",
117+
"currency-conversion/server-rates/errors",
118+
},
111119
{
112120
"Assert we correctly use request-defined custom currency rates when present in root.ext",
113-
"custom-currency/valid",
121+
"currency-conversion/custom-rates/valid",
114122
},
115123
{
116124
"Assert we correctly validate request-defined custom currency rates when present in root.ext",
117-
"custom-currency/errors",
125+
"currency-conversion/custom-rates/errors",
118126
},
119127
}
120128
for _, test := range testSuites {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"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",
3+
"config": {
4+
"currencyRates":{
5+
"USD": {
6+
"MXN": 2.00
7+
}
8+
},
9+
"mockBidder": {
10+
"currency": "USD",
11+
"price": 1.00
12+
}
13+
},
14+
"mockBidRequest": {
15+
"id": "some-request-id",
16+
"site": {
17+
"page": "test.somepage.com"
18+
},
19+
"imp": [
20+
{
21+
"id": "my-imp-id",
22+
"video": {
23+
"mimes": [
24+
"video/mp4"
25+
]
26+
},
27+
"ext": {
28+
"appnexus": {
29+
"placementId": 12883451
30+
}
31+
}
32+
}
33+
],
34+
"cur": ["GBP"],
35+
"ext": {
36+
"prebid": {
37+
"aliases": {
38+
"unknown": "appnexus"
39+
},
40+
"currency": {
41+
"rates": {
42+
"USD": {
43+
"MXN": 5.00
44+
}
45+
}
46+
}
47+
}
48+
}
49+
},
50+
"expectedReturnCode": 500,
51+
"expectedErrorMessage": "Critical error while running the auction: Can't produce bid with no valid currency to use or currency conversion to convert to."
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"description": "Despite being more expensive, custom conversion rate overrides that of the currency conversion service. usepbsrates was true",
3+
"config": {
4+
"currencyRates":{
5+
"USD": {
6+
"MXN": 2.00
7+
}
8+
},
9+
"mockBidder": {
10+
"currency": "USD",
11+
"price": 1.00
12+
}
13+
},
14+
"mockBidRequest": {
15+
"id": "some-request-id",
16+
"site": {
17+
"page": "test.somepage.com"
18+
},
19+
"imp": [
20+
{
21+
"id": "my-imp-id",
22+
"video": {
23+
"mimes": [
24+
"video/mp4"
25+
]
26+
},
27+
"ext": {
28+
"appnexus": {
29+
"placementId": 12883451
30+
}
31+
}
32+
}
33+
],
34+
"cur": ["MXN"],
35+
"ext": {
36+
"prebid": {
37+
"aliases": {
38+
"unknown": "appnexus"
39+
},
40+
"currency": {
41+
"rates": {
42+
"USD": {
43+
"CAD": 5.00
44+
}
45+
},
46+
"usepbsrates": true
47+
}
48+
}
49+
}
50+
},
51+
"expectedBidResponse": {
52+
"id":"some-request-id",
53+
"bidid":"test bid id",
54+
"cur": "MXN",
55+
"nbr":0,
56+
"seatbid": [
57+
{
58+
"bid": [
59+
{
60+
"id": "appnexus-bid",
61+
"impid": "",
62+
"price": 2.00
63+
}
64+
],
65+
"seat": "appnexus-bids"
66+
}
67+
]
68+
},
69+
"expectedReturnCode": 200
70+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"description": "bid request calls for a bid in foreign currency MXN but conversion rate is not found in the currency conversion service.",
3+
"config": {
4+
"currencyRates":{
5+
"USD": {
6+
"GBP": 0.80
7+
}
8+
},
9+
"mockBidder": {
10+
"currency": "USD",
11+
"price": 1.00
12+
}
13+
},
14+
"mockBidRequest": {
15+
"id": "some-request-id",
16+
"site": {
17+
"page": "test.somepage.com"
18+
},
19+
"cur": ["MXN"],
20+
"imp": [
21+
{
22+
"id": "my-imp-id",
23+
"video": {
24+
"mimes": [
25+
"video/mp4"
26+
]
27+
},
28+
"ext": {
29+
"appnexus": {
30+
"placementId": 12883451
31+
}
32+
}
33+
}
34+
]
35+
},
36+
"expectedReturnCode": 500,
37+
"expectedErrorMessage": "Critical error while running the auction: Can't produce bid with no valid currency to use or currency conversion to convert to."
38+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"description": "bid request calls for a bid in foreign currency but mockbidder bids in USD. Conversion rate is applied",
3+
"config": {
4+
"currencyRates":{
5+
"USD": {
6+
"MXN": 2.00
7+
}
8+
},
9+
"mockBidder": {
10+
"currency": "USD",
11+
"price": 1.00
12+
}
13+
},
14+
"mockBidRequest": {
15+
"id": "some-request-id",
16+
"site": {
17+
"page": "test.somepage.com"
18+
},
19+
"cur": ["MXN"],
20+
"imp": [
21+
{
22+
"id": "my-imp-id",
23+
"video": {
24+
"mimes": [
25+
"video/mp4"
26+
]
27+
},
28+
"ext": {
29+
"appnexus": {
30+
"placementId": 12883451
31+
}
32+
}
33+
}
34+
]
35+
},
36+
"expectedBidResponse": {
37+
"id":"some-request-id",
38+
"bidid":"test bid id",
39+
"cur": "MXN",
40+
"nbr":0,
41+
"seatbid": [
42+
{
43+
"bid": [
44+
{
45+
"id": "appnexus-bid",
46+
"impid": "",
47+
"price": 2.00
48+
}
49+
],
50+
"seat": "appnexus-bids"
51+
}
52+
]
53+
},
54+
"expectedReturnCode": 200
55+
}

0 commit comments

Comments
 (0)