Skip to content

Commit

Permalink
Remove unit test, replace it logic to json test
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhii Nahornyi committed Mar 18, 2021
1 parent 30220d4 commit 6c0d287
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 87 deletions.
73 changes: 0 additions & 73 deletions adapters/rubicon/rubicon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1320,79 +1320,6 @@ func TestOpenRTBRequestWithSpecificExtUserEids(t *testing.T) {
assert.Contains(t, userExtRPTarget["LIseg"], "999", "No segment with 999 as expected!")
}

func TestOpenRTBRequestWithTaxonomynameAttribute(t *testing.T) {
SIZE_ID := getTestSizes()
bidder := new(RubiconAdapter)

request := &openrtb.BidRequest{
ID: "test-request-id",
Imp: []openrtb.Imp{{
ID: "test-imp-id",
Banner: &openrtb.Banner{
Format: []openrtb.Format{
SIZE_ID[15],
SIZE_ID[10],
},
},
Ext: json.RawMessage(`{"bidder": {
"zoneId": 8394,
"siteId": 283282,
"accountId": 7891
}}`),
}},
User: &openrtb.User{
Data: []openrtb.Data{{
Ext: json.RawMessage(`{"taxonomyname": "iab"}`),
Segment: []openrtb.Segment{{
ID: "idToCopy",
}},
}, {
Ext: json.RawMessage(`{"taxonomyname": "someValue"}`),
Segment: []openrtb.Segment{{
ID: "shouldNotBeCopied",
}},
},
{
Ext: json.RawMessage(`{"taxonomyname": "IaB"}`),
Segment: []openrtb.Segment{{
ID: "idToCopy2",
}},
}, {
Ext: json.RawMessage(`{"taxonomyname": ["wrong iab type"]}`),
Segment: []openrtb.Segment{{
ID: "shouldNotBeCopied2",
}},
},
},
},
}

reqs, _ := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{})

rubiconReq := &openrtb.BidRequest{}
if err := json.Unmarshal(reqs[0].Body, rubiconReq); err != nil {
t.Fatalf("Unexpected error while decoding request: %s", err)
}

assert.NotNil(t, rubiconReq.User.Ext, "User.Ext object should not be nil.")

var userExt rubiconUserExt
if err := json.Unmarshal(rubiconReq.User.Ext, &userExt); err != nil {
t.Fatal("Error unmarshalling request.user.ext object.")
}

userExtRPTarget := make(map[string]interface{})
if err := json.Unmarshal(userExt.RP.Target, &userExtRPTarget); err != nil {
t.Fatal("Error unmarshalling request.user.ext.rp.target object.")
}

assert.Contains(t, userExtRPTarget, "iab", "request.user.ext.rp.target value is not as expected!")
assert.Contains(t, userExtRPTarget["iab"], "idToCopy", "No segment id idToCopy as expected!")
assert.Contains(t, userExtRPTarget["iab"], "idToCopy2", "No segment id idToCopy2 as expected!")
assert.NotContains(t, userExtRPTarget["iab"], "shouldNotBeCopied", "No segment id shouldNotBeCopied as expected!")
assert.NotContains(t, userExtRPTarget["iab"], "shouldNotBeCopied2", "No segment id shouldNotBeCopied2 as expected!")
}

func TestOpenRTBRequestWithVideoImpEvenIfImpHasBannerButAllRequiredVideoFields(t *testing.T) {
SIZE_ID := getTestSizes()
bidder := new(RubiconAdapter)
Expand Down
66 changes: 52 additions & 14 deletions adapters/rubicon/rubicontest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,43 @@
"data": [
{
"ext": {
"taxonomyname": "Iab"
"taxonomyname": "iab"
},
"segment": [
{
"id": "segmentId1"
},
"id": "idToCopy"
}
]
},
{
"ext": {
"taxonomyname": "someValue"
},
"segment": [
{
"id": "segmentId2"
"id": "shouldNotBeCopied"
}
]
},
{
"ext": {
"taxonomyname": "not i-a-b"
"taxonomyname": "IaB"
},
"segment": [
{
"id": "segmentId3"
"id": "idToCopy2"
}
]
},
{
"ext": {
"taxonomyname": [
"wrong iab type"
]
},
"segment": [
{
"id": "shouldNotBeCopied2"
}
]
}
Expand Down Expand Up @@ -83,24 +102,43 @@
"data": [
{
"ext": {
"taxonomyname": "Iab"
"taxonomyname": "iab"
},
"segment": [
{
"id": "segmentId1"
},
"id": "idToCopy"
}
]
},
{
"ext": {
"taxonomyname": "someValue"
},
"segment": [
{
"id": "shouldNotBeCopied"
}
]
},
{
"ext": {
"taxonomyname": "IaB"
},
"segment": [
{
"id": "segmentId2"
"id": "idToCopy2"
}
]
},
{
"ext": {
"taxonomyname": "not i-a-b"
"taxonomyname": [
"wrong iab type"
]
},
"segment": [
{
"id": "segmentId3"
"id": "shouldNotBeCopied2"
}
]
}
Expand All @@ -110,8 +148,8 @@
"rp": {
"target": {
"iab": [
"segmentId1",
"segmentId2"
"idToCopy",
"idToCopy2"
]
}
}
Expand Down

0 comments on commit 6c0d287

Please sign in to comment.