Skip to content

Commit 0adce5f

Browse files
author
Francois-Xavier Gsell
committed
Fix json label in audio, add unit test for audio
1 parent 4689649 commit 0adce5f

File tree

3 files changed

+120
-4
lines changed

3 files changed

+120
-4
lines changed

audio.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ type Audio struct {
2525
Delivery []int `json:"delivery,omitempty"` // List of supported delivery methods
2626
CompanionAd []Banner `json:"companionad,omitempty"`
2727
CompanionType []int `json:"companiontype,omitempty"`
28-
MaxSequence int `json:"maxseq,omitempty"` // The maximumnumber of ads that canbe played in an ad pod.
29-
Feed int `json:"companiontype,omitempty"` // Type of audio feed.
30-
Stitched int `json:"companiontype,omitempty"` // Indicates if the ad is stitched with audio content or delivered independently
31-
NVol int `json:"companiontype,omitempty"` // Volume normalization mode.
28+
MaxSequence int `json:"maxseq,omitempty"` // The maximumnumber of ads that canbe played in an ad pod.
29+
Feed int `json:"feed,omitempty"` // Type of audio feed.
30+
Stitched int `json:"stitched,omitempty"` // Indicates if the ad is stitched with audio content or delivered independently
31+
NVol int `json:"nvol,omitempty"` // Volume normalization mode.
3232
Ext Extension `json:"ext,omitempty"`
3333
}
3434

audio_test.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package openrtb
2+
3+
import (
4+
. "github.com/onsi/ginkgo"
5+
. "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("Audio", func() {
9+
var subject *Audio
10+
11+
BeforeEach(func() {
12+
err := fixture("audio", &subject)
13+
Expect(err).NotTo(HaveOccurred())
14+
})
15+
16+
It("should parse correctly", func() {
17+
Expect(subject).To(Equal(&Audio{
18+
Mimes: []string{
19+
"audio/mp4",
20+
},
21+
MinDuration: 5,
22+
MaxDuration: 30,
23+
Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper},
24+
Sequence: 1,
25+
BAttr: []int{13, 14},
26+
MaxExtended: 30,
27+
MinBitrate: 300,
28+
MaxBitrate: 1500,
29+
Delivery: []int{2},
30+
CompanionAd: []Banner{
31+
{W: 300, H: 250, ID: "1234567893-1", Pos: 1, BAttr: []int{13, 14}, ExpDir: []int{ExpDirRight, ExpDirDown}},
32+
{W: 728, H: 90, ID: "1234567893-2", Pos: 1, BAttr: []int{13, 14}},
33+
},
34+
CompanionType: []int{1, 2},
35+
}))
36+
})
37+
38+
It("should validate", func() {
39+
Expect((&Audio{
40+
MinDuration: 5,
41+
MaxDuration: 30,
42+
Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper},
43+
Sequence: 1,
44+
BAttr: []int{13, 14},
45+
MaxExtended: 30,
46+
MinBitrate: 300,
47+
MaxBitrate: 1500,
48+
Delivery: []int{2},
49+
CompanionAd: []Banner{
50+
{W: 300, H: 250, ID: "1234567893-1", Pos: 1, BAttr: []int{13, 14}, ExpDir: []int{ExpDirRight, ExpDirDown}},
51+
{W: 728, H: 90, ID: "1234567893-2", Pos: 1, BAttr: []int{13, 14}},
52+
},
53+
CompanionType: []int{1, 2},
54+
}).Validate()).To(Equal(ErrInvalidAudioNoMimes))
55+
})
56+
57+
})

testdata/audio.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"w": 640,
3+
"h": 480,
4+
"pos": 1,
5+
"startdelay": 0,
6+
"minduration": 5,
7+
"maxduration": 30,
8+
"maxextended": 30,
9+
"minbitrate": 300,
10+
"maxbitrate": 1500,
11+
"api": [
12+
1,
13+
2
14+
],
15+
"protocols": [
16+
9,
17+
10
18+
],
19+
"mimes": [
20+
"audio/mp4"
21+
],
22+
"delivery": [
23+
2
24+
],
25+
"battr": [
26+
13,
27+
14
28+
],
29+
"companionad": [
30+
{
31+
"id": "1234567893-1",
32+
"w": 300,
33+
"h": 250,
34+
"pos": 1,
35+
"battr": [
36+
13,
37+
14
38+
],
39+
"expdir": [
40+
2,
41+
4
42+
]
43+
},
44+
{
45+
"id": "1234567893-2",
46+
"w": 728,
47+
"h": 90,
48+
"pos": 1,
49+
"battr": [
50+
13,
51+
14
52+
]
53+
}
54+
],
55+
"companiontype": [
56+
1,
57+
2
58+
]
59+
}

0 commit comments

Comments
 (0)