Skip to content

Commit 5035474

Browse files
committed
Update functional tests
1 parent 0f43e43 commit 5035474

7 files changed

Lines changed: 251 additions & 175 deletions

File tree

src/test/groovy/org/prebid/server/functional/model/config/AccountAuctionConfig.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class AccountAuctionConfig {
2222
Boolean debugAllow
2323
AccountBidValidationConfig bidValidations
2424
AccountEventsConfig events
25+
AccountRankingConfig ranking
2526
AccountPriceFloorsConfig priceFloors
2627
Targeting targeting
2728
PaaFormat paaformat
@@ -31,8 +32,6 @@ class AccountAuctionConfig {
3132
PrivacySandbox privacySandbox
3233
@JsonProperty("bidadjustments")
3334
BidAdjustment bidAdjustments
34-
AuctionCacheConfig cache
35-
AuctionRankingConfig ranking
3635

3736
@JsonProperty("price_granularity")
3837
PriceGranularityType priceGranularitySnakeCase

src/test/groovy/org/prebid/server/functional/model/config/AuctionCacheConfig.groovy renamed to src/test/groovy/org/prebid/server/functional/model/config/AccountRankingConfig.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package org.prebid.server.functional.model.config
33
import groovy.transform.ToString
44

55
@ToString(includeNames = true, ignoreNulls = true)
6-
class AuctionCacheConfig {
6+
class AccountRankingConfig {
77

88
Boolean enabled
99
}

src/test/groovy/org/prebid/server/functional/model/config/AuctionRankingConfig.groovy

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import org.prebid.server.functional.model.request.auction.Imp
88
import org.prebid.server.functional.util.ObjectMapperWrapper
99
import org.prebid.server.functional.util.PBSUtils
1010

11+
import static groovy.lang.Closure.DELEGATE_FIRST
12+
1113
@ToString(includeNames = true, ignoreNulls = true)
1214
@EqualsAndHashCode
1315
class Bid implements ObjectMapperWrapper {
@@ -70,6 +72,23 @@ class Bid implements ObjectMapperWrapper {
7072
}
7173
}
7274

75+
static List<Bid> getDefaultMultyTypesBids(Imp imp, @DelegatesTo(Bid) Closure commonInit = null) {
76+
List<Bid> bids = []
77+
if (imp.banner) bids << createBid(imp, BidMediaType.BANNER) { adm = null }
78+
if (imp.video) bids << createBid(imp, BidMediaType.VIDEO)
79+
if (imp.nativeObj) bids << createBid(imp, BidMediaType.NATIVE)
80+
if (imp.audio) bids << createBid(imp, BidMediaType.AUDIO) { adm = null }
81+
82+
if (commonInit) {
83+
bids.each { bid ->
84+
commonInit.delegate = bid
85+
commonInit.resolveStrategy = DELEGATE_FIRST
86+
commonInit()
87+
}
88+
}
89+
bids
90+
}
91+
7392
void setAdm(Object adm) {
7493
if (adm instanceof Adm) {
7594
this.adm = encode(adm)
@@ -79,4 +98,15 @@ class Bid implements ObjectMapperWrapper {
7998
this.adm = null
8099
}
81100
}
101+
102+
private static Bid createBid(Imp imp, BidMediaType type, @DelegatesTo(Bid) Closure init = null) {
103+
def bid = getDefaultBid(imp)
104+
bid.mediaType = type
105+
if (init) {
106+
init.delegate = bid
107+
init.resolveStrategy = DELEGATE_FIRST
108+
init()
109+
}
110+
bid
111+
}
82112
}

src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.prebid.server.functional.tests
33
import org.prebid.server.functional.model.config.AccountAuctionConfig
44
import org.prebid.server.functional.model.config.AccountConfig
55
import org.prebid.server.functional.model.config.AccountEventsConfig
6-
import org.prebid.server.functional.model.config.AuctionCacheConfig
76
import org.prebid.server.functional.model.db.Account
87
import org.prebid.server.functional.model.request.auction.Asset
98
import org.prebid.server.functional.model.request.auction.BidRequest
@@ -15,7 +14,6 @@ import org.prebid.server.functional.model.response.auction.Adm
1514
import org.prebid.server.functional.model.response.auction.BidResponse
1615
import org.prebid.server.functional.util.PBSUtils
1716

18-
import static org.prebid.server.functional.model.AccountStatus.ACTIVE
1917
import static org.prebid.server.functional.model.response.auction.MediaType.BANNER
2018
import static org.prebid.server.functional.model.response.auction.MediaType.VIDEO
2119

@@ -494,59 +492,4 @@ class CacheSpec extends BaseSpec {
494492
PBSUtils.getRandomCase(" inline ") | " ${PBSUtils.getRandomCase(" impression ")} $PBSUtils.randomNumber "
495493
" inline ${PBSUtils.getRandomString()} " | " ImpreSSion "
496494
}
497-
498-
def "PBS should cache bids from auction when account config for auction.cache disabled"() {
499-
given: "Default BidRequest with cache, targeting"
500-
def bidRequest = BidRequest.defaultBidRequest.tap {
501-
it.enableCache()
502-
it.ext.prebid.targeting = Targeting.createWithAllValuesSetTo(true)
503-
}
504-
505-
and: "Account in the DB"
506-
def accountAuctionConfig = new AccountAuctionConfig(cache: new AuctionCacheConfig(enabled: false))
507-
def accountConfig = new AccountConfig(status: ACTIVE, auction: accountAuctionConfig)
508-
def account = new Account(uuid: bidRequest.accountId, config: accountConfig)
509-
accountDao.save(account)
510-
511-
when: "PBS processes auction request"
512-
defaultPbsService.sendAuctionRequest(bidRequest)
513-
514-
then: "PBS should call PBC"
515-
assert prebidCache.getRequestCount(bidRequest.imp[0].id) == 1
516-
517-
and: "PBS call shouldn't include api-key"
518-
assert !prebidCache.getRequestHeaders(bidRequest.imp[0].id)[PBS_API_HEADER]
519-
}
520-
521-
def "PBS should call still call vtrack endpoint when cache is disabled in account config"() {
522-
given: "Current value of metric prebid_cache.requests.ok"
523-
def initialValue = getCurrentMetricValue(defaultPbsService, CACHE_REQUEST_OK_GLOBAL_METRIC)
524-
525-
and: "Account in the DB"
526-
def accountId = PBSUtils.randomNumber.toString()
527-
def accountAuctionConfig = new AccountAuctionConfig(cache: new AuctionCacheConfig(enabled: false))
528-
def accountConfig = new AccountConfig(status: ACTIVE, auction: accountAuctionConfig)
529-
def account = new Account(uuid: accountId, config: accountConfig)
530-
accountDao.save(account)
531-
532-
and: "Default VtrackRequest"
533-
def creative = encodeXml(Vast.getDefaultVastModel(PBSUtils.randomString))
534-
def request = VtrackRequest.getDefaultVtrackRequest(creative)
535-
536-
when: "PBS processes vtrack request"
537-
def cacheResponse = defaultPbsService.sendVtrackRequest(request, accountId)
538-
539-
then: "vtrack request should be called"
540-
assert cacheResponse
541-
542-
and: "prebid_cache.creative_size.xml metric should be updated"
543-
def metrics = defaultPbsService.sendCollectedMetricsRequest()
544-
def creativeSize = creative.bytes.length
545-
assert metrics[CACHE_REQUEST_OK_GLOBAL_METRIC] == initialValue + 1
546-
assert metrics[XML_CREATIVE_SIZE_GLOBAL_METRIC] == creativeSize
547-
548-
and: "account.<account-id>.prebid_cache.creative_size.xml should be updated"
549-
assert metrics[CACHE_REQUEST_OK_ACCOUNT_METRIC.formatted(accountId)] == 1
550-
assert metrics[XML_CREATIVE_SIZE_ACCOUNT_METRIC.formatted(accountId)] == creativeSize
551-
}
552495
}

0 commit comments

Comments
 (0)