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

validateNativeContextTypes function test cases #1743

Merged
merged 2 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"description": "Native bid request. Context type content (1) is incompatible with 'social' subcontext types (20~29). Return error",
"mockBidRequest": {
"id": "req-id",
"site": {
"page": "some.page.com"
},
"tmax": 500,
"imp": [
{
"id": "some-imp",
"native": {
"request": "{\"context\":1,\"contextsubtype\":21,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}"
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
]
},
"expectedReturnCode": 400,
"expectedErrorMessage": "Invalid request"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"description": "Native bid request. Context type product (3) is incompatible with 'social' subcontext types (10~19). Return error",
"mockBidRequest": {
"id": "req-id",
"site": {
"page": "some.page.com"
},
"tmax": 500,
"imp": [
{
"id": "some-imp",
"native": {
"request": "{\"context\":3,\"contextsubtype\":11,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}"
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
]
},
"expectedReturnCode": 400,
"expectedErrorMessage": "Invalid request"
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"description": "Native bid request. Context type social (2) is incompatible with 'product' subcontext types (30~39). Return error",
"mockBidRequest": {
"id": "req-id",
"site": {
"page": "some.page.com"
},
"tmax": 500,
"imp": [
{
"id": "some-imp",
"native": {
"request": "{\"context\":2,\"contextsubtype\":31,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}"
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
]
},
"expectedReturnCode": 400,
"expectedErrorMessage": "Invalid request"
Copy link
Contributor

Choose a reason for hiding this comment

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

I see the error messages returned in the validateNativeContextTypes method to be different that what is expected in these tests. Is the error message getting overridden somewhere to this?? If so, they shouldn't be as the error messages in the validateNativeContextTypes are more informative of the problem

Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed this as well but I played with one of the tests a bit and saw that the actual error message returned by validateNativeContextTypes has Invalid Request: prepended to it and the test framework is just checking that the error message begins with whatever expectedErrorMessage is rather than doing a full string compare.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly

}


Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"description": "Native bid request comes with a subcontext type greater than 500. Return error",
"mockBidRequest": {
"id": "req-id",
"site": {
"page": "some.page.com"
},
"tmax": 500,
"imp": [
{
"id": "some-imp",
"native": {
"request": "{\"context\":1,\"contextsubtype\":550,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}"
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
]
},
"expectedReturnCode": 400,
"expectedErrorMessage": "Invalid request"
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"description": "Bid request with invalid contextsubtype value inside the native.request field in its only imp element",
"description": "Native bid request comes with a contextsubtype greater than 32, 'ContextSubTypeProductReview'",
"mockBidRequest": {
"id": "req-id",
"site": {
Expand All @@ -10,7 +10,7 @@
{
"id": "some-imp",
"native": {
"request": "{\"context\":1,\"contextsubtype\":21,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}"
"request": "{\"context\":1,\"contextsubtype\":41,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}"
},
"ext": {
"appnexus": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"description": "Native bid request comes with a context type product (3) and compatible subcontext type",
"mockBidRequest": {
"id": "req-id",
"site": {
"page": "some.page.com"
},
"tmax": 500,
"imp": [
{
"id": "some-imp",
"native": {
"request": "{\"context\":3,\"contextsubtype\":31,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}"
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
]
},
"expectedBidResponse": {
"id": "req-id",
"bidid": "test bid id",
"nbr": 0,
"seatbid": [
{
"bid": [
{
"id": "appnexus-bid",
"impid": "",
"price": 0
}
],
"seat": "appnexus-bids"
}
]
},
"expectedReturnCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"description": "Native bid request comes with a context type social (2) and compatible subcontext type",
"mockBidRequest": {
"id": "req-id",
"site": {
"page": "some.page.com"
},
"tmax": 500,
"imp": [
{
"id": "some-imp",
"native": {
"request": "{\"context\":2,\"contextsubtype\":21,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}"
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
]
},
"expectedBidResponse": {
"id": "req-id",
"bidid": "test bid id",
"nbr": 0,
"seatbid": [
{
"bid": [
{
"id": "appnexus-bid",
"impid": "",
"price": 0
}
],
"seat": "appnexus-bids"
}
]
},
"expectedReturnCode": 200
}