Skip to content
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

Modules activities #3057

Merged
merged 21 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions hooks/hookexecution/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func TestHandleModuleActivitiesBidderRequestPayload(t *testing.T) {
activityControl := privacy.NewActivityControl(test.privacyConfig)
newPayload := handleModuleActivities(test.hookCode, activityControl, test.inPayloadData)
assert.Equal(t, test.expectedPayloadData.Request.BidRequest, newPayload.Request.BidRequest)
//check input payload didn't change
origInPayloadData := test.inPayloadData
assert.Equal(t, origInPayloadData, test.inPayloadData)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to move the line origInPayloadData := test.inPayloadData above the call to handleModuleActivities.

})
}
}
Expand Down Expand Up @@ -104,6 +107,9 @@ func TestHandleModuleActivitiesProcessedAuctionRequestPayload(t *testing.T) {
activityControl := privacy.NewActivityControl(test.privacyConfig)
newPayload := handleModuleActivities(test.hookCode, activityControl, test.inPayloadData)
assert.Equal(t, test.expectedPayloadData.Request.BidRequest, newPayload.Request.BidRequest)
//check input payload didn't change
origInPayloadData := test.inPayloadData
assert.Equal(t, origInPayloadData, test.inPayloadData)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to move the line origInPayloadData := test.inPayloadData above the call to handleModuleActivities.

})
}
}
Expand Down Expand Up @@ -137,6 +143,9 @@ func TestHandleModuleActivitiesNoBidderRequestPayload(t *testing.T) {
activityControl := privacy.NewActivityControl(test.privacyConfig)
newPayload := handleModuleActivities(test.hookCode, activityControl, test.inPayloadData)
assert.Equal(t, test.expectedPayloadData, newPayload)
//check input payload didn't change
origInPayloadData := test.inPayloadData
assert.Equal(t, origInPayloadData, test.inPayloadData)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to move the line origInPayloadData := test.inPayloadData above the call to handleModuleActivities.

})
}
}
119 changes: 3 additions & 116 deletions hooks/hookexecution/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,66 +672,6 @@ func TestExecuteRawAuctionStage(t *testing.T) {
},
},
},
{
description: "Group payload not changes with transmitUFPD activity restriction",
givenBody: body,
givenUrl: urlString,
givenPlanBuilder: TestWithModuleContextsPlanBuilder{},
givenAccount: account,
expectedBody: body,
expectedReject: nil,
expectedModuleContexts: &moduleContexts{ctxs: map[string]hookstage.ModuleContext{
"module-1": {"raw-auction-ctx-1": "some-ctx-1", "raw-auction-ctx-3": "some-ctx-3"},
"module-2": {"raw-auction-ctx-2": "some-ctx-2"},
}},
privacyConfig: getTransmitUFPDActivityConfig("foo", false),
expectedStageOutcomes: []StageOutcome{
{
Entity: entityAuctionRequest,
Stage: hooks.StageRawAuctionRequest.String(),
Groups: []GroupOutcome{
{
InvocationResults: []HookOutcome{
{
AnalyticsTags: hookanalytics.Analytics{},
HookID: HookID{ModuleCode: "module-1", HookImplCode: "foo"},
Status: StatusSuccess,
Action: ActionNone,
Message: "",
DebugMessages: nil,
Errors: nil,
Warnings: nil,
},
{
AnalyticsTags: hookanalytics.Analytics{},
HookID: HookID{ModuleCode: "module-2", HookImplCode: "baz"},
Status: StatusSuccess,
Action: ActionNone,
Message: "",
DebugMessages: nil,
Errors: nil,
Warnings: nil,
},
},
},
{
InvocationResults: []HookOutcome{
{
AnalyticsTags: hookanalytics.Analytics{},
HookID: HookID{ModuleCode: "module-1", HookImplCode: "bar"},
Status: StatusSuccess,
Action: ActionNone,
Message: "",
DebugMessages: nil,
Errors: nil,
Warnings: nil,
},
},
},
},
},
},
},
}

for _, test := range testCases {
Expand Down Expand Up @@ -1231,68 +1171,15 @@ func TestExecuteBidderRequestStage(t *testing.T) {
},
},
},
{
description: "Group payload not changes with transmitUFPD activity restriction",
givenBidderRequest: &openrtb2.BidRequest{ID: "some-id", User: &openrtb2.User{ID: "user-id"}},
givenPlanBuilder: TestWithModuleContextsPlanBuilder{},
givenAccount: account,
expectedBidderRequest: expectedBidderRequest,
expectedReject: nil,
expectedModuleContexts: &moduleContexts{ctxs: map[string]hookstage.ModuleContext{
"module-1": {"bidder-request-ctx-1": "some-ctx-1"},
"module-2": {"bidder-request-ctx-2": "some-ctx-2"},
}},
privacyConfig: getTransmitUFPDActivityConfig("foo", false),
expectedStageOutcomes: []StageOutcome{
{
ExecutionTime: ExecutionTime{},
Entity: entity(bidderName),
Stage: hooks.StageBidderRequest.String(),
Groups: []GroupOutcome{
{
ExecutionTime: ExecutionTime{},
InvocationResults: []HookOutcome{
{
ExecutionTime: ExecutionTime{},
AnalyticsTags: hookanalytics.Analytics{},
HookID: HookID{ModuleCode: "module-1", HookImplCode: "foo"},
Status: StatusSuccess,
Action: ActionNone,
Message: "",
DebugMessages: nil,
Errors: nil,
Warnings: nil,
},
},
},
{
ExecutionTime: ExecutionTime{},
InvocationResults: []HookOutcome{
{
ExecutionTime: ExecutionTime{},
AnalyticsTags: hookanalytics.Analytics{},
HookID: HookID{ModuleCode: "module-2", HookImplCode: "bar"},
Status: StatusSuccess,
Action: ActionNone,
Message: "",
DebugMessages: nil,
Errors: nil,
Warnings: nil,
},
},
},
},
},
},
},
}

for _, test := range testCases {
t.Run(test.description, func(t *testing.T) {
exec := NewHookExecutor(test.givenPlanBuilder, EndpointAuction, &metricsConfig.NilMetricsEngine{})
exec.SetAccount(test.givenAccount)
ac := privacy.NewActivityControl(test.privacyConfig)
privacyConfig := getTransmitUFPDActivityConfig("foo", false)
ac := privacy.NewActivityControl(privacyConfig)
exec.SetActivityControl(ac)
exec.SetAccount(test.givenAccount)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to add this to all six stage tests?

  • TestExecuteRawAuctionStage
  • TestExecuteProcessedAuctionStage
  • TestExecuteBidderRequestStage
  • TestExecuteRawBidderResponseStage
  • TestExecuteAllProcessedBidResponsesStage
  • TestExecuteAuctionResponseStage


reject := exec.ExecuteBidderRequestStage(&openrtb_ext.RequestWrapper{BidRequest: test.givenBidderRequest}, bidderName)

Expand Down