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

New Adapter: Mediasquare #3994

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

mediasquare-alexandre
Copy link
Contributor

@mediasquare-alexandre mediasquare-alexandre commented Oct 18, 2024

Summary
This PR introduces the Mediasquare bidder adapter for Prebid Server. It supports the following mediatypes:

  • Banner
  • Video
  • Native

Endpoint: "https://pbs-front.mediasquare.fr/msq_prebid"
Endpoint Compression: gzip
GVL Vendor ID: 791

Test Status
Unit tests: All tests passed.

Maintainer Contact
emails:

About us
https://www.mediasquare.fr/

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, f49cc00

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:73:	makeRequest		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:94:	MakeBids		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:16:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:45:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:24:		mType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:36:		bidType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:48:		extBid			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:59:		loadExtBid		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:78:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:88:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:96:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:102:		errorWritter		100.0%
total:										(statements)		99.4%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 355ddb0

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:73:	makeRequest		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:94:	MakeBids		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:16:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:45:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:24:		mType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:36:		bidType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:48:		extBid			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:59:		loadExtBid		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:78:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:88:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:96:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:102:		errorWritter		100.0%
total:										(statements)		99.4%

@mediasquare-alexandre mediasquare-alexandre changed the title New Adapter Mediasquare New Adapter: Mediasquare Oct 24, 2024
@przemkaczmarek przemkaczmarek self-assigned this Oct 30, 2024
@przemkaczmarek przemkaczmarek self-requested a review October 30, 2024 11:55
@@ -0,0 +1,12 @@
endpoint: "http://pbs-front.mediasquare.fr/msq_prebid"
Copy link
Collaborator

Choose a reason for hiding this comment

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

image

503 response, please fix

@przemkaczmarek
Copy link
Collaborator

@mediasquare-alexandre Hi, I’m wondering why these tests were written in this way. In most adapters, we approach it by having a TestJsonSamples class, where we write JSON files to check our scenarios, like simple-banner.json, bad_media_type, etc. Additionally, we add a params_test class to verify validParams and invalidParams.
Were you aware of this pattern?
@bsardo we should decide if we accept these new adapters in this form.

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, c7221a2

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:73:	makeRequest		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:94:	MakeBids		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:16:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:45:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:24:		mType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:36:		bidType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:48:		extBid			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:59:		loadExtBid		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:78:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:88:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:96:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:102:		errorWritter		100.0%
total:										(statements)		99.4%

@mediasquare-alexandre
Copy link
Contributor Author

mediasquare-alexandre commented Oct 30, 2024

@mediasquare-alexandre Hi, I’m wondering why these tests were written in this way. In most adapters, we approach it by having a TestJsonSamples class, where we write JSON files to check our scenarios, like simple-banner.json, bad_media_type, etc. Additionally, we add a params_test class to verify validParams and invalidParams. Were you aware of this pattern? @bsardo we should decide if we accept these new adapters in this form.

Hi Guys, honestly when I started doing my tests I remembered my PR 2 years ago here where most of my reviewers asked me to increase the code-coverage as much as possible. #2215
So I took a look on the package which has been authorized in my last PR and adjust the code as much as possible to increase the cover-rate. Just hope I didn't do bad by doing so for you guys @przemkaczmarek @bsardo
I'm waiting for your reply, I have already fixed the problem you put to light @przemkaczmarek

Copy link

github-actions bot commented Nov 3, 2024

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 747bff3

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:73:	makeRequest		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:94:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:16:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:45:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:24:		mType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:36:		bidType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:48:		extBid			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:59:		loadExtBid		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:78:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:88:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:96:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:102:		errorWritter		100.0%
total:										(statements)		99.4%

Copy link

github-actions bot commented Nov 3, 2024

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 8de23e9

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:73:	makeRequest		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:94:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:16:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:45:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:24:		mType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:36:		bidType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:48:		extBid			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:59:		loadExtBid		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:78:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:88:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:96:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:102:		errorWritter		100.0%
total:										(statements)		99.4%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 0a0e2b2

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:73:	makeRequest		66.7%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:95:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:16:		setContent		60.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:45:		setContent		60.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:25:		mType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:37:		bidType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:49:		extBid			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:60:		loadExtBid		90.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:79:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:89:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:97:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:103:		errorWritter		100.0%
total:										(statements)		94.5%

@mediasquare-alexandre
Copy link
Contributor Author

Hi Guys, @przemkaczmarek @bsardo
Code-Tests has been rewrote using your adapterstest.RunJSONBidderTest methods.
Hope everything is ok, waiting for earing from you guys.
I'm up if any update is needed.

}

msqParams := initMsqParams(request)
msqParams.Test = (request.Test == int8(1))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't seen this behavior before. Is this added because the msqParams.Test field is required by the MediaSquare backend to recognize the request as a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is.

@przemkaczmarek
Copy link
Collaborator

@mediasquare-alexandre It's great that you decided to add the adapterstest.RunJSONBidderTest methods.
Next, you should write JSON files like this:
image

Comment on lines +21 to +26
// MakeRequests : case request is empty.
resp, errs := bidder.MakeRequests(nil, nil)
expectingErrors := []error{errorWritter("<MakeRequests> request", nil, true)}
assert.Equal(t, []*adapters.RequestData(nil), resp, "resp, was supposed to be empty result.")
assert.Equal(t, expectingErrors, errs, "errs, was supposed to be :", expectingErrors)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be tested in JSON files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially would have if it was possible,

// MakeRequests : case request is empty.
resp, errs := bidder.MakeRequests(nil, nil)

Here is a screen-shot of the following test :
nil-imp

Cordially

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have had, let this test be :
image
Tell me if you want me to take it back, it will reduce the coverage by 2% or so... But it is not critical.

@przemkaczmarek
Copy link
Collaborator

@mediasquare-alexandre This still doesn't meet our standards, e.g., there's no params_test.go file where you would test validParams and invalidParams (for your required owner and code).
I’m not sure if anyone has informed you how this should look, but please check our page: https://docs.prebid.org/prebid-server/developers/add-new-bidder-go.html.
There, you’ll find all the information on how a new adapter should look, including all the required tests.

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 01c1674

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:73:	makeRequest		66.7%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:95:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:16:		setContent		60.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:45:		setContent		60.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:25:		mType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:37:		bidType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:49:		extBid			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:60:		loadExtBid		90.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:79:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:89:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:97:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:103:		errorWritter		100.0%
total:										(statements)		94.5%

@mediasquare-alexandre
Copy link
Contributor Author

@przemkaczmarek I tried to use your naming for tests-files, but I'm not sure the names I put on are ok... The documentation only show that files have to be formated as json in supplemental & examplary, so it doesn't help me neither on this subject.
Sincerly-yours,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants