-
Notifications
You must be signed in to change notification settings - Fork 769
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: Seedtag #4198
base: master
Are you sure you want to change the base?
New Adapter: Seedtag #4198
Conversation
Code coverage summaryNote:
seedtagRefer here for heat map coverage report
|
@ccorbo can you give this the first look? |
@@ -0,0 +1,69 @@ | |||
{ |
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.
could you add a test where you receive a bid with an unexpected mtype?
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.
added this test and also a test for currency conversion errors
…quest on currency conversion error
Code coverage summaryNote:
seedtagRefer here for heat map coverage report
|
The 400 error is expected if not providing an OpenRtb well formed payload |
|
||
var invalidParams = []string{ | ||
`{"adUnitId": 123}`, | ||
`{"adUnitId": ""}`, |
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.
Since adUnitId
is a required param, I suggest adding a case where adUnitId
is not provided: {}
adapters/seedtag/seedtag_test.go
Outdated
|
||
func TestJsonSamples(t *testing.T) { | ||
bidder, buildErr := Builder(openrtb_ext.BidderSeedtag, config.Adapter{ | ||
Endpoint: "https://s.seedtag.com"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) |
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.
Nitpick: I suggest using a test url for maintenance purposes.
adapters/seedtag/seedtag.go
Outdated
if responseData.StatusCode == http.StatusNoContent { | ||
return nil, nil | ||
} | ||
|
||
if responseData.StatusCode == http.StatusBadRequest { | ||
return nil, []error{&errortypes.BadInput{ | ||
Message: fmt.Sprintf("unexpected status code: %d. Run with request.debug = 1 for more info", responseData.StatusCode), | ||
}} | ||
} | ||
|
||
if responseData.StatusCode != http.StatusOK { | ||
return nil, []error{fmt.Errorf("unexpected status code: %d. Run with request.debug = 1 for more info", responseData.StatusCode)} | ||
} |
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.
I understand that the prebid docs do not reflect this yet but please use the adapter utility functions adapters/response.go#IsResponseStatusCodeNoContent
and adapters/response.go#CheckResponseStatusCodeForErrors
to handle invalid status codes.
adapters/seedtag/seedtag.go
Outdated
|
||
requestCopy := *request | ||
requestCopy.Imp = imps | ||
requestJSON, err := json.Marshal(requestCopy) |
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 use jsonutil.Marshal
instead of json.Marshal
.
adapters/seedtag/seedtag.go
Outdated
return nil, []error{err} | ||
} | ||
|
||
bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) |
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.
Nitpick: It might be better to size this based on the number of valid impressions rather than the initial number of impressions. You should be able to access the valid impression count via requestData.ImpIDs
.
adapters/seedtag/seedtag.go
Outdated
case 2: | ||
return openrtb_ext.BidTypeVideo, nil | ||
default: | ||
return "", fmt.Errorf("bid.MType invalid") |
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.
Nitpick: I suggest errors.New
for errors that are just string literals.
adapters/seedtag/seedtag_test.go
Outdated
adapterstest.RunJSONBidderTest(t, "seedtagtest", bidder) | ||
} | ||
|
||
func TestGetMediaTypeForBid(t *testing.T) { |
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.
All code coverage should be achieved via the JSON framework wherever possible. You've achieved full coverage of the GetMediaTypeForBid
function through your JSON tests so I don't see this unit test offering much value. I suggest deleting it but you can keep it if you like.
If you decide to keep it, please do the following:
- replace all spaces in your test names with underscores (e.g.
"video mediaType"
becomes"video_mediaType"
- fix typo "invalie"
- replace body with the following using
t.Run
and removingwantErrContain
:
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var bid openrtb2.Bid
bid.MType = openrtb2.MarkupType(test.value)
got, gotErr := getMediaTypeForBid(bid)
assert.Equal(t, test.want, got)
if test.wantErr {
assert.Error(t, gotErr)
}
})
}
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.
right! I just removed it
imp.BidFloorCur = "USD" | ||
imp.BidFloor = convertedValue |
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.
These two lines are missing test coverage. Please add a supplemental JSON test where a successful currency conversion takes place.
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.
test added
|
||
var response openrtb2.BidResponse | ||
if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { | ||
return nil, []error{err} |
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 a supplemental JSON test where the response body unmarshaling fails.
Code coverage summaryNote:
seedtagRefer here for heat map coverage report
|
Hi @bsardo I've done all changes you pointed out, thanks for the catches ;) |
documentation PR - prebid/prebid.github.io#5866