From 345ea63e6b31f416da5157bd487efbf2b2f72421 Mon Sep 17 00:00:00 2001 From: "ashish.shinde" Date: Thu, 18 Apr 2024 20:22:41 +0530 Subject: [PATCH] add json unit test cases --- exchange/exchange_test.go | 3 +- .../exchangetest/floors_deal_enforcement.json | 147 ++++++++++++++++++ 2 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 exchange/exchangetest/floors_deal_enforcement.json diff --git a/exchange/exchange_test.go b/exchange/exchange_test.go index 87c3936f8b2..1e6db356ba7 100644 --- a/exchange/exchange_test.go +++ b/exchange/exchange_test.go @@ -2187,7 +2187,7 @@ func runSpec(t *testing.T, filename string, spec *exchangeSpec) { Enabled: spec.EventsEnabled, }, DebugAllow: true, - PriceFloors: config.AccountPriceFloors{Enabled: spec.AccountFloorsEnabled}, + PriceFloors: config.AccountPriceFloors{Enabled: spec.AccountFloorsEnabled, EnforceDealFloors: spec.AccountEnforceDealFloors}, Privacy: spec.AccountPrivacy, Validations: spec.AccountConfigBidValidation, }, @@ -5493,6 +5493,7 @@ type exchangeSpec struct { HostConfigBidValidation config.Validations `json:"host_bid_validations"` AccountConfigBidValidation config.Validations `json:"account_bid_validations"` AccountFloorsEnabled bool `json:"account_floors_enabled"` + AccountEnforceDealFloors bool `json:"account_enforce_deal_floors"` FledgeEnabled bool `json:"fledge_enabled,omitempty"` MultiBid *multiBidSpec `json:"multiBid,omitempty"` Server exchangeServer `json:"server,omitempty"` diff --git a/exchange/exchangetest/floors_deal_enforcement.json b/exchange/exchangetest/floors_deal_enforcement.json new file mode 100644 index 00000000000..924fd2f7719 --- /dev/null +++ b/exchange/exchangetest/floors_deal_enforcement.json @@ -0,0 +1,147 @@ +{ + "floors_enabled": true, + "account_floors_enabled": true, + "account_enforce_deal_floors": true, + "incomingRequest": { + "ortbRequest": { + "id": "request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [ + { + "id": "imp-id", + "video": { + "mimes": [ + "video/mp4" + ] + }, + "bidfloor": 20, + "bidfloorcur": "USD", + "ext": { + "prebid": { + "bidder": { + "appnexus": { + "placementId": 1 + }, + "pubmatic": { + "publisherId": "1234" + } + } + } + } + } + ], + "ext": { + "prebid": { + "floors": { + "enabled": true, + "enforcement": { + "floordeals": true, + "enforcerate": 100 + } + } + } + } + } + }, + "outgoingRequests": { + "appnexus": { + "mockResponse": { + "pbsSeatBids": [ + { + "pbsBids": [ + { + "ortbBid": { + "id": "apnx-bid-id", + "dealid": "apnx-deal-id", + "impid": "imp-id", + "price": 5, + "w": 200, + "h": 250, + "crid": "creative-1" + } + } + ], + "seat": "appnexus", + "currency": "USD" + } + ] + } + }, + "pubmatic": { + "mockResponse": { + "pbsSeatBids": [ + { + "pbsBids": [ + { + "ortbBid": { + "id": "pubm-bid-id", + "impid": "imp-id", + "price": 10, + "w": 200, + "h": 250, + "crid": "creative-1" + } + } + ], + "seat": "pubmatic", + "currency": "USD" + } + ] + } + } + }, + "response": { + "bids": {}, + "ext": { + "prebid": { + "seatnonbid": [ + { + "nonbid": [ + { + "impid": "imp-id", + "statuscode": 304, + "ext": { + "prebid": { + "bid": { + "price": 5, + "w": 200, + "h": 250, + "crid": "creative-1", + "origbidcpm": 5, + "dealid": "apnx-deal-id" + } + } + } + } + ], + "seat": "appnexus", + "ext": null + }, + { + "nonbid": [ + { + "impid": "imp-id", + "statuscode": 301, + "ext": { + "prebid": { + "bid": { + "price": 10, + "w": 200, + "h": 250, + "crid": "creative-1", + "origbidcpm": 10 + } + } + } + } + ], + "seat": "pubmatic", + "ext": null + } + ] + } + } + } + }