-
Notifications
You must be signed in to change notification settings - Fork 224
Tests: Increase coverage for floors validation #3741
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add import static org.prebid.server.functional.model.bidder.BidderName.GENERIC
src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy
Show resolved
Hide resolved
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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] |
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.
Same here
src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy
Show resolved
Hide resolved
src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy
Show resolved
Hide resolved
| given: "Test start time" | ||
| def startTime = Instant.now() | ||
|
|
||
| and: "Bid request with floors" |
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.
Bid request without floors?
| given: "Test start time" | ||
| def startTime = Instant.now() |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why invalid?
And getAccountWithEnabledFetch is creating to fetch.enabled = true
src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy
Show resolved
Hide resolved
| } | ||
|
|
||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove comment
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
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.
Same as previous
| 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" |
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.
Same
| def bidRequest = bidRequestWithFloors.tap { | ||
| ext.prebid.floors = null | ||
| } |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need here bidder response
| and: "Set bidder response" | ||
| def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) | ||
| bidder.setResponse(bidRequest.id, bidResponse) |
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.
Same here
| and: "Set bidder response" | ||
| def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) | ||
| bidder.setResponse(bidRequest.id, bidResponse) |
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.
Same here
| bidder.setResponse(bidRequest.id, bidResponse) | ||
|
|
||
| and: "PBS fetch rules from floors provider" | ||
| cacheFloorsProviderRules(bidRequest, floorsPbsService, GENERIC, SUCCESS) |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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