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: BrightMountainMedia #1855

Merged
merged 12 commits into from
Jun 9, 2021
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
4 changes: 2 additions & 2 deletions adapters/bmtm/brightmountainmedia.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ func (a *adapter) makeRequest(ortbRequest openrtb2.BidRequest, ortbImp openrtb2.
var bidderExt adapters.ExtImpBidder
if err := json.Unmarshal(ortbImp.Ext, &bidderExt); err != nil {
return nil, &errortypes.BadInput{
Message: "Error unmarshalling ExtImpBidder",
Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()),
}
}

var bmtmExt openrtb_ext.ImpExtBmtm
if err := json.Unmarshal(bidderExt.Bidder, &bmtmExt); err != nil {
return nil, &errortypes.BadInput{
Message: "Error unmarshalling ExtImpBmtm",
Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()),
}
}

Expand Down
4 changes: 3 additions & 1 deletion adapters/bmtm/brightmountainmedia_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package bmtm

import (
"fmt"
"testing"

"github.com/prebid/prebid-server/adapters/adapterstest"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/stretchr/testify/assert"
)

func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderBmtm, config.Adapter{
Endpoint: "https://example.com/api/pbs"})

if buildErr != nil {
mansinahar marked this conversation as resolved.
Show resolved Hide resolved
BrightMountainMediaInc marked this conversation as resolved.
Show resolved Hide resolved
t.Fatalf("Builder returned unexpected error %v", buildErr)
assert.NoError(t, buildErr, fmt.Sprintf("Builder returned unexpected error: %s", buildErr.Error()))
}

adapterstest.RunJSONBidderTest(t, "brightmountainmediatest", bidder)
Expand Down
10 changes: 6 additions & 4 deletions adapters/bmtm/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,35 @@ package bmtm

import (
"encoding/json"
"fmt"
"testing"

"github.com/prebid/prebid-server/openrtb_ext"
"github.com/stretchr/testify/assert"
)

func TestValidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
mansinahar marked this conversation as resolved.
Show resolved Hide resolved
BrightMountainMediaInc marked this conversation as resolved.
Show resolved Hide resolved
t.Fatalf("Failed to fetch the json-schemas. %v", err)
assert.NoError(t, err, fmt.Sprintf("Failed to fetch the json-schemas: %s", err.Error()))
}

for _, validParam := range validParams {
if err := validator.Validate(openrtb_ext.BidderBmtm, json.RawMessage(validParam)); err != nil {
mansinahar marked this conversation as resolved.
Show resolved Hide resolved
BrightMountainMediaInc marked this conversation as resolved.
Show resolved Hide resolved
t.Errorf("Schema rejected brightMountainMedia params: %s", validParam)
assert.NoError(t, err, fmt.Sprintf("Schema rejected brightMountainMedia params: %s", validParam))
}
}
}

func TestInvalidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
mansinahar marked this conversation as resolved.
Show resolved Hide resolved
BrightMountainMediaInc marked this conversation as resolved.
Show resolved Hide resolved
t.Fatalf("Failed to fetch the json-schemas. %v", err)
assert.NoError(t, err, fmt.Sprintf("Failed to fetch the json-schemas: %s", err.Error()))
}

for _, invalidParam := range invalidParams {
if err := validator.Validate(openrtb_ext.BidderBmtm, json.RawMessage(invalidParam)); err == nil {
BrightMountainMediaInc marked this conversation as resolved.
Show resolved Hide resolved
t.Errorf("Schema allowed unexpected params: %s", invalidParam)
assert.NoError(t, err, fmt.Sprintf("Schema allowed unexpected params: %s", invalidParam))
}
}
}
Expand Down