From abd794089fcbc043d9e644fb1329b7b0f37f5f9c Mon Sep 17 00:00:00 2001 From: Max Cherry Date: Wed, 28 Feb 2018 09:36:46 +0200 Subject: [PATCH] Native 1.2: copied/adapted awful 1.2 examples for tests --- native/request/request_test.go | 21 ++++- .../testdata/v1.1}/README.md | 2 +- .../testdata/{ => v1.1}/content-context.json | 0 .../testdata/{ => v1.1}/social-context.json | 0 native/request/testdata/v1.2/README.md | 10 +++ .../testdata/v1.2/content-context.json | 78 +++++++++++++++++++ .../request/testdata/v1.2/social-context.json | 58 ++++++++++++++ native/request/testdata/v1.2/third-party.json | 50 ++++++++++++ native/response/response_test.go | 21 ++++- .../testdata/v1.1}/README.md | 0 .../testdata/{ => v1.1}/clickout.json | 0 .../response/testdata/{ => v1.1}/video.json | 0 native/response/testdata/v1.2/README.md | 6 ++ native/response/testdata/v1.2/clickout.json | 51 ++++++++++++ .../response/testdata/v1.2/third-party.json | 42 ++++++++++ native/response/testdata/v1.2/video.json | 47 +++++++++++ 16 files changed, 377 insertions(+), 9 deletions(-) rename native/{response/testdata => request/testdata/v1.1}/README.md (97%) rename native/request/testdata/{ => v1.1}/content-context.json (100%) rename native/request/testdata/{ => v1.1}/social-context.json (100%) create mode 100644 native/request/testdata/v1.2/README.md create mode 100644 native/request/testdata/v1.2/content-context.json create mode 100644 native/request/testdata/v1.2/social-context.json create mode 100644 native/request/testdata/v1.2/third-party.json rename native/{request/testdata => response/testdata/v1.1}/README.md (100%) rename native/response/testdata/{ => v1.1}/clickout.json (100%) rename native/response/testdata/{ => v1.1}/video.json (100%) create mode 100644 native/response/testdata/v1.2/README.md create mode 100644 native/response/testdata/v1.2/clickout.json create mode 100644 native/response/testdata/v1.2/third-party.json create mode 100644 native/response/testdata/v1.2/video.json diff --git a/native/request/request_test.go b/native/request/request_test.go index 0cacb9e..6ae8f48 100644 --- a/native/request/request_test.go +++ b/native/request/request_test.go @@ -29,12 +29,25 @@ var _ = Describe("Request", func() { }, Entry( - "Social Context", - "social-context.json", + "Social Context (v1.1)", + "v1.1/social-context.json", new(Request)), Entry( - "Content Context", - "content-context.json", + "Content Context (v1.1)", + "v1.1/content-context.json", + new(Request)), + + Entry( + "Social Context (v1.2)", + "v1.2/social-context.json", + new(Request)), + Entry( + "Content Context (v1.2)", + "v1.2/content-context.json", + new(Request)), + Entry( + "Third-party (v1.2)", + "v1.2/third-party.json", new(Request)), ) }) diff --git a/native/response/testdata/README.md b/native/request/testdata/v1.1/README.md similarity index 97% rename from native/response/testdata/README.md rename to native/request/testdata/v1.1/README.md index 20c5d0b..8809268 100644 --- a/native/response/testdata/README.md +++ b/native/request/testdata/v1.1/README.md @@ -1,4 +1,4 @@ -# testdata +# v1.1 JSON examples copied from [OpenRTB](https://www.iab.com/guidelines/real-time-bidding-rtb-project/) [Dynamic Native Ads API Specification Version 1.1](https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-Native-Ads-Specification-1-1_2016.pdf) spec - section 6 Bid Request/Response Samples. diff --git a/native/request/testdata/content-context.json b/native/request/testdata/v1.1/content-context.json similarity index 100% rename from native/request/testdata/content-context.json rename to native/request/testdata/v1.1/content-context.json diff --git a/native/request/testdata/social-context.json b/native/request/testdata/v1.1/social-context.json similarity index 100% rename from native/request/testdata/social-context.json rename to native/request/testdata/v1.1/social-context.json diff --git a/native/request/testdata/v1.2/README.md b/native/request/testdata/v1.2/README.md new file mode 100644 index 0000000..80f1311 --- /dev/null +++ b/native/request/testdata/v1.2/README.md @@ -0,0 +1,10 @@ +# v1.2 + +JSON examples copied from [OpenRTB](https://www.iab.com/guidelines/real-time-bidding-rtb-project/) [Dynamic Native Ads API +Specification Version 1.2](https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf) spec - section 6 Bid Request/Response Samples. + +Some empty/zero attributes were omited (not copied) because of [encoding/json](https://golang.org/pkg/encoding/json/) `omitempty` and [gomega.MatchJSON(...)](http://onsi.github.io/gomega/#matchjsonjson-interface). + +Some parts were adapted due too poor quality of examples in spec: +- `eventtrackers`: called `eventtrackers` in spec, but `eventrackers` in example +- `eventtrackers`: request example included response `eventrrackers` diff --git a/native/request/testdata/v1.2/content-context.json b/native/request/testdata/v1.2/content-context.json new file mode 100644 index 0000000..1672bf1 --- /dev/null +++ b/native/request/testdata/v1.2/content-context.json @@ -0,0 +1,78 @@ +{ + "ver": "1.2", + "context": 1, + "contextsubtype": 10, + "plcmttype": 11, + "plcmtcnt": 1, + "privacy": 1, + "eventtrackers": [{ + "event": 1, + "methods": [1, 2] + }, + { + "event": 2, + "methods": [1] + } + ], + "assets": [{ + "id": 4, + "video": { + "minduration": 15, + "maxduration": 30, + "protocols": [ + 2, 3 + ], + "mimes": [ + "video/mp4" + ] + } + }, + { + "id": 123, + "required": 1, + "title": { + "len": 140 + } + }, + { + "id": 128, + "img": { + "wmin": 836, + "hmin": 627, + "type": 3 + } + }, + { + "id": 124, + "required": 1, + "img": { + "wmin": 50, + "hmin": 50, + "type": 1 + } + }, + { + "id": 126, + "required": 1, + "data": { + "type": 1, + "len": 25 + } + }, + { + "id": 127, + "required": 1, + "data": { + "type": 2, + "len": 140 + } + } + ], + "eventtrackers": [{ + "event": 1, + "methods": [2] + }, { + "event": 2, + "methods": [1] + }] +} diff --git a/native/request/testdata/v1.2/social-context.json b/native/request/testdata/v1.2/social-context.json new file mode 100644 index 0000000..0b3dc1e --- /dev/null +++ b/native/request/testdata/v1.2/social-context.json @@ -0,0 +1,58 @@ +{ + "ver": "1.2", + "context": 2, + "contextsubtype": 20, + "plcmttype": 11, + "plcmtcnt": 1, + "privacy": 1, + "eventtrackers": [{ + "event": 1, + "methods": [1, 2] + }, + { + "event": 2, + "methods": [1] + } + ], + "assets": [{ + "id": 123, + "required": 1, + "title": { + "len": 140 + } + }, + { + "id": 128, + "img": { + "wmin": 836, + "hmin": 627, + "type": 3 + } + }, + { + "id": 124, + "required": 1, + "img": { + "wmin": 50, + "hmin": 50, + "type": 1 + } + }, + { + "id": 126, + "required": 1, + "data": { + "type": 1, + "len": 25 + } + }, + { + "id": 127, + "required": 1, + "data": { + "type": 2, + "len": 140 + } + } + ] +} diff --git a/native/request/testdata/v1.2/third-party.json b/native/request/testdata/v1.2/third-party.json new file mode 100644 index 0000000..8b549d5 --- /dev/null +++ b/native/request/testdata/v1.2/third-party.json @@ -0,0 +1,50 @@ +{ + "ver": "1.2", + "context": 2, + "contextsubtype": 20, + "plcmttype": 11, + "plcmtcnt": 1, + "aurlsupport": 1, + "durlsupport": 1, + "assets": [{ + "id": 123, + "required": 1, + "title": { + "len": 140 + } + }, + { + "id": 128, + "img": { + "wmin": 836, + "hmin": 627, + "type": 3 + } + }, + { + "id": 124, + "required": 1, + "img": { + "wmin": 50, + "hmin": 50, + "type": 1 + } + }, + { + "id": 126, + "required": 1, + "data": { + "type": 1, + "len": 25 + } + }, + { + "id": 127, + "required": 1, + "data": { + "type": 2, + "len": 140 + } + } + ] +} diff --git a/native/response/response_test.go b/native/response/response_test.go index df74c4b..b7f7cca 100644 --- a/native/response/response_test.go +++ b/native/response/response_test.go @@ -29,12 +29,25 @@ var _ = Describe("Response", func() { }, Entry( - "Clickout", - "clickout.json", + "Clickout (v1.1)", + "v1.1/clickout.json", new(Response)), Entry( - "Video", - "video.json", + "Video (v1.1)", + "v1.1/video.json", + new(Response)), + + Entry( + "Clickout (v1.2)", + "v1.2/clickout.json", + new(Response)), + Entry( + "Video (v1.2)", + "v1.2/video.json", + new(Response)), + Entry( + "Third-party (v1.2)", + "v1.2/third-party.json", new(Response)), ) }) diff --git a/native/request/testdata/README.md b/native/response/testdata/v1.1/README.md similarity index 100% rename from native/request/testdata/README.md rename to native/response/testdata/v1.1/README.md diff --git a/native/response/testdata/clickout.json b/native/response/testdata/v1.1/clickout.json similarity index 100% rename from native/response/testdata/clickout.json rename to native/response/testdata/v1.1/clickout.json diff --git a/native/response/testdata/video.json b/native/response/testdata/v1.1/video.json similarity index 100% rename from native/response/testdata/video.json rename to native/response/testdata/v1.1/video.json diff --git a/native/response/testdata/v1.2/README.md b/native/response/testdata/v1.2/README.md new file mode 100644 index 0000000..cf3439c --- /dev/null +++ b/native/response/testdata/v1.2/README.md @@ -0,0 +1,6 @@ +# v1.2 + +JSON examples copied from [OpenRTB](https://www.iab.com/guidelines/real-time-bidding-rtb-project/) [Dynamic Native Ads API +Specification Version 1.2](https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf) spec - section 6 Bid Request/Response Samples. + +Some empty/zero attributes were omited (not copied) because of [encoding/json](https://golang.org/pkg/encoding/json/) `omitempty` and [gomega.MatchJSON(...)](http://onsi.github.io/gomega/#matchjsonjson-interface). diff --git a/native/response/testdata/v1.2/clickout.json b/native/response/testdata/v1.2/clickout.json new file mode 100644 index 0000000..0fccd99 --- /dev/null +++ b/native/response/testdata/v1.2/clickout.json @@ -0,0 +1,51 @@ +{ + "link": { + "url": "http://i.am.a/URL" + }, + "assets": [{ + "id": 123, + "required": 1, + "title": { + "text": "Learn about this awesome thing" + } + }, + { + "id": 124, + "required": 1, + "img": { + "url": "http://www.myads.com/thumbnail1.png" + } + }, + { + "id": 128, + "required": 1, + "img": { + "url": "http://www.myads.com/largethumb1.png" + } + }, + { + "id": 126, + "required": 1, + "data": { + "value": "My Brand" + } + }, + { + "id": 127, + "required": 1, + "data": { + "value": "Learn all about this awesome story of someone using my product." + } + } + ], + "eventtrackers": [{ + "event": 1, + "method": 2, + "url": "http://www.mytracker.com/tracker.js" + }, { + "event": 2, + "method": 1, + "url": "http://www.mytracker.com/tracker.php" + }], + "privacy": "http://www.myprivacyurl.com" + } diff --git a/native/response/testdata/v1.2/third-party.json b/native/response/testdata/v1.2/third-party.json new file mode 100644 index 0000000..86ed599 --- /dev/null +++ b/native/response/testdata/v1.2/third-party.json @@ -0,0 +1,42 @@ +{ + "assetsurl": "http://www.myadserver.com/getad123nativejson.php", + "link": { + "url": "http: //i.am.a/URL" + }, + "assets": [{ + "id": 123, + "required": 1, + "title": { + "text": "Learn about this awesome thing" + } + }, + { + "id": 124, + "required": 1, + "img": { + "url": "http://www.myads.com/thumbnail1.png" + } + }, + { + "id": 128, + "required": 1, + "img": { + "url": "http://www.myads.com/largethumb1.png" + } + }, + { + "id": 126, + "required": 1, + "data": { + "value": "My Brand" + } + }, + { + "id": 127, + "required": 1, + "data": { + "value": "Learn all about this awesome story of someone using my product." + } + } + ] + } diff --git a/native/response/testdata/v1.2/video.json b/native/response/testdata/v1.2/video.json new file mode 100644 index 0000000..304a275 --- /dev/null +++ b/native/response/testdata/v1.2/video.json @@ -0,0 +1,47 @@ + { + "link": { + "url": "http: //i.am.a/URL" + }, + "assets": [{ + "id": 4, + "video": { + "vasttag": "" + } + }, + { + "id": 123, + "required": 1, + "title": { + "text": "Watch this awesome thing" + } + }, + { + "id": 124, + "required": 1, + "img": { + "url": "http://www.myads.com/thumbnail1.png" + } + }, + { + "id": 128, + "required": 1, + "img": { + "url": "http://www.myads.com/largethumb1.png" + } + }, + { + "id": 126, + "required": 1, + "data": { + "value": "My Brand" + } + }, + { + "id": 127, + "required": 1, + "data": { + "value": "Watch all about this awesome story of someone using my product." + } + } + ] + }