Skip to content

Commit 7670bae

Browse files
committed
Get the basic augury test working
1 parent b24c264 commit 7670bae

File tree

2 files changed

+227
-2
lines changed

2 files changed

+227
-2
lines changed

test/fixtures/placements.json

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
{
2+
"count": 3,
3+
"total": 3,
4+
"_embedded": {
5+
"prx:items": [
6+
{
7+
"id": 3063,
8+
"name": "One Segment",
9+
"originalCount": 1,
10+
"zones": [
11+
{
12+
"id": "original_1",
13+
"name": "Original 1",
14+
"type": "original",
15+
"section": "original"
16+
},
17+
{
18+
"id": "sonic_id",
19+
"name": "Sonic",
20+
"type": "sonic_id",
21+
"section": "post"
22+
}
23+
],
24+
"_links": {
25+
"self": {
26+
"href": "/api/v1/inventory/5678/placements/3063",
27+
"profile": "http://meta.prx.org/model/application-record/placement"
28+
},
29+
"profile": {
30+
"href": "http://meta.prx.org/model/application-record/placement"
31+
}
32+
}
33+
},
34+
{
35+
"id": 3129,
36+
"name": "Two Segments",
37+
"originalCount": 2,
38+
"zones": [
39+
{
40+
"id": "house_pre",
41+
"name": "House Preroll",
42+
"type": "ad",
43+
"section": "pre"
44+
},
45+
{
46+
"id": "original_1",
47+
"name": "Original 1",
48+
"type": "original",
49+
"section": "original"
50+
},
51+
{
52+
"id": "mid_1",
53+
"name": "Midroll 1",
54+
"type": "ad",
55+
"section": "mid"
56+
},
57+
{
58+
"id": "mid_2",
59+
"name": "Midroll 2",
60+
"type": "ad",
61+
"section": "mid"
62+
},
63+
{
64+
"id": "original_2",
65+
"name": "Original 2",
66+
"type": "original",
67+
"section": "original"
68+
},
69+
{
70+
"id": "post_1",
71+
"name": "Postroll 1",
72+
"type": "ad",
73+
"section": "post"
74+
},
75+
{
76+
"id": "post_2",
77+
"name": "Postroll 2",
78+
"type": "ad",
79+
"section": "post"
80+
},
81+
{
82+
"id": "house_post",
83+
"name": "House Postroll",
84+
"type": "ad",
85+
"section": "post"
86+
},
87+
{
88+
"id": "sonic_id",
89+
"name": "Sonic",
90+
"type": "sonic_id",
91+
"section": "post"
92+
}
93+
],
94+
"_links": {
95+
"self": {
96+
"href": "/api/v1/inventory/5678/placements/3129",
97+
"profile": "http://meta.prx.org/model/application-record/placement"
98+
},
99+
"profile": {
100+
"href": "http://meta.prx.org/model/application-record/placement"
101+
}
102+
}
103+
},
104+
{
105+
"id": 3064,
106+
"name": "Three Segments",
107+
"originalCount": 3,
108+
"zones": [
109+
{
110+
"id": "house_pre",
111+
"name": "House Preroll",
112+
"type": "ad",
113+
"section": "pre"
114+
},
115+
{
116+
"id": "original_1",
117+
"name": "Original 1 (Intro)",
118+
"type": "original",
119+
"section": "original"
120+
},
121+
{
122+
"id": "pre_1",
123+
"name": "Preroll 1",
124+
"type": "ad",
125+
"section": "pre"
126+
},
127+
{
128+
"id": "pre_2",
129+
"name": "Preroll 2",
130+
"type": "ad",
131+
"section": "pre"
132+
},
133+
{
134+
"id": "original_2",
135+
"name": "Original 2",
136+
"type": "original",
137+
"section": "original"
138+
},
139+
{
140+
"id": "mid_1",
141+
"name": "Midroll 1",
142+
"type": "ad",
143+
"section": "mid"
144+
},
145+
{
146+
"id": "mid_2",
147+
"name": "Midroll 2",
148+
"type": "ad",
149+
"section": "mid"
150+
},
151+
{
152+
"id": "original_3",
153+
"name": "Original 3",
154+
"type": "original",
155+
"section": "original"
156+
},
157+
{
158+
"id": "post_1",
159+
"name": "Postroll 1",
160+
"type": "ad",
161+
"section": "post"
162+
},
163+
{
164+
"id": "post_2",
165+
"name": "Postroll 2",
166+
"type": "ad",
167+
"section": "post"
168+
},
169+
{
170+
"id": "house_post",
171+
"name": "House Postroll",
172+
"type": "ad",
173+
"section": "post"
174+
},
175+
{
176+
"id": "sonic_id",
177+
"name": "Sonic",
178+
"type": "sonic_id",
179+
"section": "post"
180+
}
181+
],
182+
"_links": {
183+
"self": {
184+
"href": "/api/v1/inventory/5678/placements/3064",
185+
"profile": "http://meta.prx.org/model/application-record/placement"
186+
},
187+
"profile": {
188+
"href": "http://meta.prx.org/model/application-record/placement"
189+
}
190+
}
191+
}
192+
]
193+
},
194+
"_links": {
195+
"self": {
196+
"href": "/api/v1/podcasts/1234/placements",
197+
"profile": "http://meta.prx.org/model/collection/application-record/placement"
198+
},
199+
"prx:vary": {
200+
"href": "/api/v1/podcasts/1234/placements{?page,per,zoom,filters,sorts}",
201+
"templated": true
202+
},
203+
"profile": {
204+
"href": "http://meta.prx.org/model/collection/application-record/placement"
205+
},
206+
"curies": [
207+
{
208+
"name": "prx",
209+
"href": "http://meta.prx.org/relation/{rel}",
210+
"templated": true
211+
}
212+
]
213+
}
214+
}

test/models/prx/augury_test.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
require "test_helper"
22

33
describe Prx::Augury do
4-
let(augury) { Prx::Augury.new }
4+
let(:augury) { Prx::Augury.new }
5+
6+
before {
7+
stub_request(:post, 'https://id.prx.org/token')
8+
.to_return(status: 200,
9+
body: '{"access_token":"thisisnotatoken","token_type":"bearer"}',
10+
headers: {"Content-Type" => "application/json; charset=utf-8"})
11+
12+
stub_request(:get, "https://inventory.dovetail.prx.org/api/v1/podcasts/1234/placements")
13+
.to_return(status: 200, body: json_file(:placements), headers: {})
14+
}
515

616
it "retrieves placements" do
7-
assert augury.placements(1234)
17+
placements = augury.placements(1234)
18+
assert placements.collect { |p| p.original_count } == [1, 2, 3]
819
end
920
end

0 commit comments

Comments
 (0)