Tests: Record a default core bid ranking#3833
Conversation
| then: "PBS should rank bid with deal as top priority" | ||
| def bids = response.seatbid.first.bid | ||
| assert bids.find(it -> it.id == bidBDeal.id).ext.prebid.rank == 1 | ||
| assert bids.find(it -> it.id == bidBiggerPrice.id).ext.prebid.rank == 2 |
There was a problem hiding this comment.
I hope bid.price (highest first)
| assert bids.find(it -> it.id == bidBiggerPrice.id).ext.prebid.rank == 2 | ||
| } | ||
|
|
||
| def "PBS should ignore bid ranked from original response when auction.ranking default"() { |
There was a problem hiding this comment.
Here we can add a where block and add a case for default and false, and we should receive the same result
| and: "Account in the DB" | ||
| def accountAuctionConfig = new AccountAuctionConfig(ranking: new AuctionRankingConfig(enabled: true)) | ||
| def accountConfig = new AccountConfig(status: ACTIVE, auction: accountAuctionConfig) | ||
| def account = new Account(uuid: bidRequest.accountId, config: accountConfig) | ||
| accountDao.save(account) |
There was a problem hiding this comment.
Can be in a static method like getAccountConfigWithEnabledAuctionRanking()
|
|
||
| and: "Account in the DB" | ||
| def accountId = PBSUtils.randomNumber.toString() | ||
|
|
| @@ -0,0 +1,6 @@ | |||
| package org.prebid.server.functional.model.config | |||
|
|
|||
| class AuctionCacheConfig { | |||
There was a problem hiding this comment.
@tostring(includeNames = true, ignoreNulls = true)
| @@ -0,0 +1,6 @@ | |||
| package org.prebid.server.functional.model.config | |||
|
|
|||
| class AuctionRankingConfig { | |||
There was a problem hiding this comment.
@tostring(includeNames = true, ignoreNulls = true)
…unctional-tests/bid-ranking
5035474 to
34428bb
Compare
…unctional-tests/bid-ranking # Conflicts: # src/test/groovy/org/prebid/server/functional/model/config/AccountAuctionConfig.groovy
| ] | ||
| } | ||
|
|
||
| def "PBS shouldn't add bid ranked for multiple media types request when account config for auction.ranking disabled or default"() { |
There was a problem hiding this comment.
I would leave only a one such test that starts with PBS shouldn't add bid ranked, because ranking depends on multibid config and not vice versa, so those tests look redundant except for the fact they check the bid ranking config
| def response = defaultPbsService.sendAuctionRequest(bidRequest) | ||
|
|
||
| then: "PBS should rank single bid" | ||
| assert response.seatbid.first.bid?.ext?.prebid?.rank?.flatten() == [1] |
There was a problem hiding this comment.
I'd say the bid ranking feature make sense only when there are at least two bids in order to cover correctness of the sorting logic
in the particular test it mentions preferDeals but it can't be covered because only one bid is present
if you want to show that the second bid was removed due to multibid config I still suggest using another valid bid in order to show that the ranking isn't broken
e.g.
multibid1.price = 1
multibid2.price = 2
bid3.price = 0.5
the result is multibid2.rank = 1, bid3.rank = 2 (not 3)
| assert response.seatbid.first.bid?.ext?.prebid?.rank?.flatten() == [1] | ||
| } | ||
|
|
||
| def "PBS should add bid ranked and rank by deals for request with multiBid when auction.ranking and preferDeals are enabled"() { |
There was a problem hiding this comment.
one important thing that is missed in tests is understanding that the sorting and ranking happens within an imp, and I don't see any test mention it while it's a core requirement and I don't see any test covers two bids for different imps that have the same rank
| } | ||
| } | ||
|
|
||
| static List<Bid> getDefaultMultyTypesBids(Imp imp, @DelegatesTo(Bid) Closure commonInit = null) { |
| assert bids.find(it -> it.id == bidBiggerPrice.id).ext.prebid.rank == 2 | ||
| } | ||
|
|
||
| def "PBS should add bid ranked and rank by deals for multiple media types request when auction.ranking and preferDeals are enabled"() { |
There was a problem hiding this comment.
I don't understand the difference between this test and PBS should add bid ranked and rank by deals for request with multiBid when auction.ranking and preferDeals are enabled
looks like the set up is pretty much the same, and the multiple media type request doesn't have any impact on the outcome, since the outcome is mocked identically
| assert bids.find(it -> it.id == bidBiggerPrice.id).ext.prebid.rank == 1 | ||
| assert bids.find(it -> it.id == bidBDeal.id).ext.prebid.rank == 2 |
There was a problem hiding this comment.
Please consider to replace magic 1 and 2 numbers with something meaningful
| it.price = bidPrice + 1 | ||
| it.ext = new BidExt(prebid: new Prebid(rank: PBSUtils.randomNumber)) | ||
| } | ||
| def bidBDeal = Bid.getDefaultBid(bidRequest.imp[0]).tap { |
There was a problem hiding this comment.
Rename with like bidWithDealId
| def prebidServerService = pbsServiceFactory.getService(pbsConfig) | ||
|
|
||
| and: "Bid request with multiple bidders" | ||
| def bidRequest = BidRequest.getDefaultVideoRequest().tap { |
| assert bids.find(it -> it.id == lowerPriceBid.id).ext.prebid.rank == 2 | ||
|
|
||
| and: "PBS should contain error for invalid bid" | ||
| assert response.ext.errors[ErrorType.GENERIC]?.message?.any { it.contains(middlePriceBid.id) } |
There was a problem hiding this comment.
Can you add proper assets for error with the full sentence
There was a problem hiding this comment.
This is not a validation test case. It shouldn’t matter what error is here — main task is to verify that PBS sets ranks correctly
|
|
||
| def middlePriceBid = Bid.getDefaultBid(bidRequest.imp.first).tap { | ||
| price = bidPrice + 1 | ||
| adm = null |
There was a problem hiding this comment.
adm was removed to provoke a bid error; it could be any type of error except for a pricing one.
An error with adm just popped into my mind first, that’s all
🔧 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