Skip to content

Commit

Permalink
Added x-amples tests for newly stored endpoints.
Browse files Browse the repository at this point in the history
Change-Id: I6a466d03c7b45e14edd916b7d9b6b028cdc0c9ac
  • Loading branch information
Pchelolo committed Jul 24, 2019
1 parent 5ce0bad commit 08a6668
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 5 deletions.
21 changes: 20 additions & 1 deletion v1/pcs/media-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,25 @@ paths:
schema:
$ref: '#/components/schemas/problem'
operationId: getContent
x-monitor: false
x-monitor: true
x-amples:
- title: Get media-list from storage
request:
params:
domain: en.wikipedia.org
title: User:BSitzmann_(WMF)/MCS/Test/Frankenstein
response:
status: 200
headers:
etag: /.+/
content-type: /^application\/json/
body:
revision: /\d+/
tid: /.+/
items:
- type: /.+/
section_id: /\d+/
showInGallery: /.+/

/media-list/{title}/{revision}:
x-route-filters: *media_list_title_filters
Expand Down Expand Up @@ -112,6 +130,7 @@ paths:
type: boolean
operationId: getContentWithRevision
x-monitor: false

components:
schemas:
titles_set:
Expand Down
32 changes: 31 additions & 1 deletion v1/pcs/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,35 @@ paths:
schema:
$ref: '#/components/schemas/problem'
operationId: getContent
x-monitor: false
x-monitor: true
x-amples:
- title: Get metadata from storage
request:
params:
domain: en.wikipedia.org
title: User:BSitzmann_(WMF)/MCS/Test/Frankenstein
response:
status: 200
headers:
etag: /.+/
content-type: /^application\/json/
body:
revision: /.+/
tid: /.+/
hatnotes:
- section: /.+/
html: /.+/
toc:
title: /.+/
entries:
- level: /.+/
section: /.+/
number: /.+/
anchor: /.+/
html: /.+/
protection:
edit: [ /.+/ ]
move: [ /.+/ ]

/metadata/{title}/{revision}:
x-route-filters:
Expand Down Expand Up @@ -110,6 +138,8 @@ paths:
schema:
type: boolean
operationId: getContentWithRevision
x-monitor: false

components:
schemas:
metadata:
Expand Down
15 changes: 14 additions & 1 deletion v1/pcs/mobile-html.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,19 @@ paths:
schema:
$ref: '#/components/schemas/problem'
operationId: getContent
x-monitor: false
x-monitor: true
x-amples:
- title: Get mobile-html from storage
request:
params:
domain: en.wikipedia.org
title: User:BSitzmann_(WMF)/MCS/Test/Frankenstein
response:
status: 200
headers:
etag: /.+/
content-type: /^text\/html.+/
body: /^<!DOCTYPE html>.*/

/mobile-html/{title}/{revision}:
x-route-filters:
Expand Down Expand Up @@ -138,3 +150,4 @@ paths:
schema:
type: boolean
operationId: getContentWithRevision
x-monitor: false
24 changes: 23 additions & 1 deletion v1/pcs/references.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,28 @@ paths:
schema:
$ref: '#/components/schemas/problem'
operationId: getContent
x-monitor: false
x-monitor: true
x-amples:
- title: Get references from storage
request:
params:
domain: en.wikipedia.org
title: User:BSitzmann_(WMF)/MCS/Test/Frankenstein
response:
status: 200
headers:
etag: /.+/
content-type: /^application\/json/
body:
revision: /.+/
tid: /.+/
reference_lists:
- id: /.*/
section_heading:
id: /.+/
html: /.+/
order: [ /.*/ ]
references_by_id: /.+/

/references/{title}/{revision}:
x-route-filters:
Expand Down Expand Up @@ -111,6 +132,7 @@ paths:
schema:
type: boolean
operationId: getContentWithRevision
x-monitor: false

# copied from MCS spec.yaml
components:
Expand Down
8 changes: 7 additions & 1 deletion v1/pcs/stored_endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ class PCSEndpoint {
return res;
}
const revision = mwUtils.parseETag(res.headers.etag).rev;
let bodyToStore;
if (/^application\/json.*/.test(res.headers['content-type'])) {
bodyToStore = Buffer.from(JSON.stringify(res.body));
} else {
bodyToStore = Buffer.from(res.body);
}
return hyper.put({
uri: new URI([rp.domain, 'sys', 'key_value', this._options.name, rp.title]),
headers: {
Expand All @@ -99,7 +105,7 @@ class PCSEndpoint {
'x-store-content-type': res.headers['content-type'],
'x-store-vary': res.headers.vary
},
body: Buffer.from(JSON.stringify(res.body))
body: bodyToStore
})
.tap(() => this._purgeURIs(hyper, req, revision))
.thenReturn(res);
Expand Down

0 comments on commit 08a6668

Please sign in to comment.