Tests: Increase coverage for floors validation#3741
Conversation
|
|
||
| and: "PBS fetch rules from floors provider" | ||
| cacheFloorsProviderRules(bidRequest, floorsPbsService) | ||
| cacheFloorsProviderRules(bidRequest, floorsPbsService, BidderName.GENERIC, NONE) |
There was a problem hiding this comment.
Add import static org.prebid.server.functional.model.bidder.BidderName.GENERIC
| and: "Metric alerts.account_config.ACCOUNT.price-floors should be update" | ||
| def metrics = floorsPbsService.sendCollectedMetricsRequest() | ||
| assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 | ||
| assert !metrics[ALERT_GENERAL] |
There was a problem hiding this comment.
Please add separate "and" section for this assert
| and: "Metric alerts.account_config.ACCOUNT.price-floors should be update" | ||
| def metrics = floorsPbsService.sendCollectedMetricsRequest() | ||
| assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 | ||
| assert !metrics[ALERT_GENERAL] |
| given: "Test start time" | ||
| def startTime = Instant.now() | ||
|
|
||
| and: "Bid request with floors" |
There was a problem hiding this comment.
Bid request without floors?
| given: "Test start time" | ||
| def startTime = Instant.now() |
There was a problem hiding this comment.
We have a global startTime variable
…into functional-tests/floors-validation
| then: "PBS should log a warning" | ||
| def message = "Using dynamic data is not allowed" | ||
| assert response.ext?.warnings[PREBID]*.code == [999] | ||
| assert response.ext?.warnings[PREBID]*.message == [message] |
There was a problem hiding this comment.
Can be in line:
assert response.ext?.warnings[PREBID]*.message == ["Using dynamic data is not allowed"]
| and: "Account with invalid floors config" | ||
| def account = getAccountWithEnabledFetch(bidRequest.accountId).tap { | ||
| config.auction.priceFloors.fetch.enabled = true | ||
| } |
There was a problem hiding this comment.
Why invalid?
And getAccountWithEnabledFetch is creating to fetch.enabled = true
| } | ||
|
|
||
| def "PBS should emit errors when stored request has more rules than price-floor.max-rules for amp request"() { | ||
| // @IgnoreRest |
There was a problem hiding this comment.
Please check other occurrences
| assert metrics[FETCH_FAILURE_METRIC] == 1 | ||
|
|
||
| and: "PBS log should contain error" | ||
| def message = "Price floor modelGroup skipRate must be in range(0-100), but was $invalidSkipRate" |
There was a problem hiding this comment.
Message can be global constant for FetchingSpec
| ["Failed to parse price floors from request, with a reason: Price floor modelGroup modelWeight " + | ||
| "must be in range(1-100), but was $invalidModelWeight"] | ||
| and: "Response should contain warning" | ||
| def message = "Price floor modelGroup modelWeight must be in range(1-100), but was $invalidModelWeight" |
| assert metrics[FETCH_FAILURE_METRIC] == 1 | ||
|
|
||
| and: "PBS log should contain error" | ||
| def message = "Price floor rules values can't be null or empty, but were null" |
| def bidRequest = bidRequestWithFloors.tap { | ||
| ext.prebid.floors = null | ||
| } |
There was a problem hiding this comment.
Why can't we use getDefaultBidRequest()?
| and: "Set bidder response" | ||
| def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) | ||
| bidder.setResponse(bidRequest.id, bidResponse) |
There was a problem hiding this comment.
We don't need here bidder response
| and: "Set bidder response" | ||
| def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) | ||
| bidder.setResponse(bidRequest.id, bidResponse) |
| and: "Set bidder response" | ||
| def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) | ||
| bidder.setResponse(bidRequest.id, bidResponse) |
| bidder.setResponse(bidRequest.id, bidResponse) | ||
|
|
||
| and: "PBS fetch rules from floors provider" | ||
| cacheFloorsProviderRules(bidRequest, floorsPbsService, GENERIC, SUCCESS) |
There was a problem hiding this comment.
Just cacheFloorsProviderRules(bidRequest)
| and: "PBS request status shouldn't be in progress" | ||
| def bidderRequest = bidder.getBidderRequests(bidRequest.id) | ||
| assert getRequests(bidResponse)[GENERIC.value]?.first?.ext?.prebid?.floors?.fetchStatus == NONE | ||
| assert bidderRequest.ext.prebid.floors.fetchStatus == [NONE] |
There was a problem hiding this comment.
Please split these two assertions by and: sections
|
|
||
| and: "Account with enabled fetching" | ||
| def account = getAccountWithEnabledFetch(bidRequest.accountId).tap { | ||
| config.auction.priceFloors.fetch.enabled = true |
There was a problem hiding this comment.
getAccountWithEnabledFetch() already setup enabled to true
🔧 Type of changes
✨ What's the context?
What's the context for the changes?
🧠 Rationale behind the change
Why did you choose to make these changes? Were there any trade-offs you had to consider?
🔎 New Bid Adapter Checklist
🧪 Test plan
How do you know the changes are safe to ship to production?
🏎 Quality check