This repository has been archived by the owner on Oct 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple tests (JSON marshalling); deprecated User.BuyerID proper…
…ty (in favor of User.BuyerUID)
- Loading branch information
Showing
14 changed files
with
477 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package openrtb_test | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/mxmCherry/openrtb" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/ginkgo/extensions/table" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestOpenRTB(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "OpenRTB") | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
var _ = DescribeTable( | ||
"Marshalling", | ||
func(filename string, subject interface{}) { | ||
|
||
expected, err := ioutil.ReadFile(filepath.Join("testdata", filename)) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
Expect(json.Unmarshal(expected, subject)).To(Succeed()) | ||
|
||
actual, err := json.Marshal(subject) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
Expect(actual).To(MatchJSON(expected)) | ||
}, | ||
Entry( | ||
"Bid Request - Simple Banner", | ||
"bid-request-simple-banner.json", | ||
new(openrtb.BidRequest)), | ||
Entry( | ||
"Bid Request - Expandable Creative", | ||
"bid-request-expandable-creative.json", | ||
new(openrtb.BidRequest)), | ||
Entry( | ||
"Bid Request - Mobile", | ||
"bid-request-mobile.json", | ||
new(openrtb.BidRequest)), | ||
Entry( | ||
"Bid Request - Video", | ||
"bid-request-video.json", | ||
new(openrtb.BidRequest)), | ||
Entry( | ||
"Bid Request - PMP with Direct Deal", | ||
"bid-request-pmp-with-direct-deal.json", | ||
new(openrtb.BidRequest)), | ||
Entry( | ||
"Bid Request - Native Ad", | ||
"bid-request-native-ad.json", | ||
new(openrtb.BidRequest)), | ||
|
||
Entry( | ||
"Bid Response - Ad Served on Win Notice", | ||
"bid-response-ad-served-on-win-notice.json", | ||
new(openrtb.BidResponse)), | ||
Entry( | ||
"Bid Response - VAST XML Document Returned Inline", | ||
"bid-response-vast-xml-document-returned-inline.json", | ||
new(openrtb.BidResponse)), | ||
Entry( | ||
"Bid Response - Direct Deal Ad Served on Win Notice", | ||
"bid-response-direct-deal-ad-served-on-win-notice.json", | ||
new(openrtb.BidResponse)), | ||
Entry( | ||
"Bid Response - Native Markup Returned Inline", | ||
"bid-response-native-markup-returned-inline.json", | ||
new(openrtb.BidResponse)), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Testdata | ||
|
||
JSON examples copied from [OpenRTB](//github.com/openrtb/OpenRTB) [v2.3.1](//github.com/openrtb/OpenRTB/blob/master/OpenRTB-API-Specification-Version-2-3-1-FINAL.pdf) spec - section 6. Bid Request/Response Samples. | ||
|
||
Some empty/zero attributes (like `imp[i].banner.pos == 0`) were omited because of [encoding/json](//golang.org/pkg/encoding/json/) `omitempty` and [gomega.MatchJSON(...)](//onsi.github.io/gomega/#matchjsonjson-interface). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"id": "123456789316e6ede735f123ef6e32361bfc7b22", | ||
"at": 2, | ||
"cur": ["USD"], | ||
"imp": [{ | ||
"id": "1", | ||
"bidfloor": 0.03, | ||
"iframebuster": ["vendor1.com", "vendor2.com"], | ||
"banner": { | ||
"h": 250, | ||
"w": 300, | ||
"battr": [13], | ||
"expdir": [2, 4] | ||
} | ||
}], | ||
"site": { | ||
"id": "102855", | ||
"cat": ["IAB3-1"], | ||
"domain": "www.foobar.com", | ||
"page": "http://www.foobar.com/1234.html", | ||
"publisher": { | ||
"id": "8953", | ||
"name": "foobar.com", | ||
"cat": ["IAB3-1"], | ||
"domain": "foobar.com" | ||
} | ||
}, | ||
"device": { | ||
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version / 5.1 .7 Safari / 534.57 .2 ", | ||
"ip": "123.145.167.10" | ||
}, | ||
"user": { | ||
"id": "55816b39711f9b5acf3b90e313ed29e51665623f", | ||
"buyeruid": "545678765467876567898765678987654", | ||
"data": [{ | ||
"id": "6", | ||
"name": "Data Provider 1", | ||
"segment": [{ | ||
"id": "12341318394918", | ||
"name": "auto intenders" | ||
}, { | ||
"id": "1234131839491234", | ||
"name": "auto enthusiasts" | ||
}, { | ||
"id": "23423424", | ||
"name": "data-provider1-age", | ||
"value": "30-40" | ||
}] | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"id": "IxexyLDIIk", | ||
"at": 2, | ||
"bcat": ["IAB25", "IAB7-39", "IAB8-18", "IAB8-5", "IAB9-9"], | ||
"badv": ["apple.com", "go-text.me", "heywire.com"], | ||
"imp": [{ | ||
"id": "1", | ||
"bidfloor": 0.5, | ||
"tagid": "agltb3B1Yi1pbmNyDQsSBFNpdGUY7fD0FAw", | ||
"banner": { | ||
"w": 728, | ||
"h": 90, | ||
"pos": 1, | ||
"btype": [4], | ||
"battr": [14], | ||
"api": [3] | ||
} | ||
}], | ||
"app": { | ||
"id": "agltb3B1Yi1pbmNyDAsSA0FwcBiJkfIUDA", | ||
"name": "Yahoo Weather", | ||
"cat": ["IAB15", "IAB15-10"], | ||
"ver": "1.0.2", | ||
"bundle": "com.yahoo.wxapp", | ||
"storeurl": "https://itunes.apple.com/id628677149", | ||
"publisher": { | ||
"id": "agltb3B1Yi1pbmNyDAsSA0FwcBiJkfTUCV", | ||
"name": "yahoo", | ||
"domain": "www.yahoo.com" | ||
} | ||
}, | ||
"device": { | ||
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit / 534.46(KHTML, like Gecko) Version / 5.1 Mobile / 9 A334 Safari / 7534.48 .3 ", | ||
"ip": "123.145.167.189", | ||
"ifa": "AA000DFE74168477C70D291f574D344790E0BB11", | ||
"carrier": "VERIZON", | ||
"language": "en", | ||
"make": "Apple", | ||
"model": "iPhone", | ||
"os": "iOS", | ||
"osv": "6.1", | ||
"js": 1, | ||
"connectiontype": 3, | ||
"devicetype": 1, | ||
"geo": { | ||
"lat": 35.012345, | ||
"lon": -115.12345, | ||
"country": "USA", | ||
"metro": "803", | ||
"region": "CA", | ||
"city": "Los Angeles", | ||
"zip": "90049" | ||
} | ||
}, | ||
"user": { | ||
"id": "ffffffd5135596709273b3a1a07e466ea2bf4fff", | ||
"yob": 1984, | ||
"gender": "M" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"id": "80ce30c53c16e6ede735f123ef6e32361bfc7b22", | ||
"at": 1, | ||
"cur": ["USD"], | ||
"imp": [{ | ||
"id": "1", | ||
"bidfloor": 0.03, | ||
"native": { | ||
"request": "...Native Spec request as an encoded string...", | ||
"ver": "1.0", | ||
"api": [3], | ||
"battr": [13, 14] | ||
} | ||
}], | ||
"site": { | ||
"id": "102855", | ||
"cat": ["IAB3-1"], | ||
"domain": "www.foobar.com", | ||
"page": "http://www.foobar.com/1234.html ", | ||
"publisher": { | ||
"id": "8953", | ||
"name": "foobar.com", | ||
"cat": ["IAB3-1"], | ||
"domain": "foobar.com" | ||
} | ||
}, | ||
"device": { | ||
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version / 5.1 .7 Safari / 534.57 .2 ", | ||
"ip": "123.145.167.10" | ||
}, | ||
"user": { | ||
"id": "55816b39711f9b5acf3b90e313ed29e51665623f" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"id": "80ce30c53c16e6ede735f123ef6e32361bfc7b22", | ||
"at": 1, | ||
"cur": ["USD"], | ||
"imp": [{ | ||
"id": "1", | ||
"bidfloor": 0.03, | ||
"banner": { | ||
"h": 250, | ||
"w": 300 | ||
}, | ||
"pmp": { | ||
"private_auction": 1, | ||
"deals": [{ | ||
"id": "AB-Agency1-0001", | ||
"at": 1, | ||
"bidfloor": 2.5, | ||
"wseat": ["Agency1"] | ||
}, { | ||
"id": "XY-Agency2-0001", | ||
"at": 2, | ||
"bidfloor": 2, | ||
"wseat": ["Agency2"] | ||
}] | ||
} | ||
}], | ||
"site": { | ||
"id": "102855", | ||
"domain": "www.foobar.com", | ||
"cat": ["IAB3-1"], | ||
"page": "http://www.foobar.com/1234.html", | ||
"publisher": { | ||
"id": "8953", | ||
"name": "foobar.com", | ||
"cat": ["IAB3-1"], | ||
"domain": "foobar.com" | ||
} | ||
}, | ||
"device": { | ||
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version / 5.1 .7 Safari / 534.57 .2 ", | ||
"ip": "123.145.167.10" | ||
}, | ||
"user": { | ||
"id": "55816b39711f9b5acf3b90e313ed29e51665623f" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"id": "80ce30c53c16e6ede735f123ef6e32361bfc7b22", | ||
"at": 1, | ||
"cur": ["USD"], | ||
"imp": [{ | ||
"id": "1", | ||
"bidfloor": 0.03, | ||
"banner": { | ||
"h": 250, | ||
"w": 300 | ||
} | ||
}], | ||
"site": { | ||
"id": "102855", | ||
"cat": ["IAB3-1"], | ||
"domain": "www.foobar.com", | ||
"page": "http://www.foobar.com/1234.html ", | ||
"publisher": { | ||
"id": "8953", | ||
"name": "foobar.com", | ||
"cat": ["IAB3-1"], | ||
"domain": "foobar.com" | ||
} | ||
}, | ||
"device": { | ||
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version / 5.1 .7 Safari / 534.57 .2 ", | ||
"ip": "123.145.167.10" | ||
}, | ||
"user": { | ||
"id": "55816b39711f9b5acf3b90e313ed29e51665623f" | ||
} | ||
} |
Oops, something went wrong.