Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
anaysis endpoint mock
Browse files Browse the repository at this point in the history
  • Loading branch information
aszac committed Jan 21, 2016
1 parent 9c150e4 commit 8761e88
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 50 deletions.
75 changes: 29 additions & 46 deletions pylon/analyze.feature
Original file line number Diff line number Diff line change
@@ -1,63 +1,46 @@
Feature: POST /pylon/analyze

Scenario: Analyze with valid parameters
Given that the request body is valid JSON
"""
{
"id": "1234",
"parameters": [
{
"analysis_type": "freqDist",
"parameters": {
"target": "fb.author.gender",
"threshold": 0
}
}
],
"start": 1453191346,
"end": 1453191346,
"filter": "interaction.sample <= 100"
}
"""
When I make a "POST" request to "/v1.3/pylon/analyze"
Then the response status code should be "200"
And the response body contains the JSON data
Given a mock exists
And returns this body and status code "200" at the path "/behat-v1.3/pylon/analyze"
"""
{
"truncated":true,
"interations":10,
"unique_authors":20,
"results": [
{
"male" : 30,
"female": 40,
"unknown": 10
}
]
}
"""
When an analysis request is made with recording id "1234", analysisType "freqDist", parameters interval "hour" and target "fb.author.gender"
Then the analyze response status code should be "200"
And the analyze response body contains the JSON data
"""
{
"truncated":true,
"interations":10,
"unique_authors":20,
"results": [
{
"male" : 30,
"female": 40,
"unknown": 10
}
{
"male" : 30,
"female": 40,
"unknown": 10
}
]
}
"""

Scenario: Analyze without id
Given that the request body is valid JSON
"""
{
"parameters": [
{
"analysis_type": "freqDist",
"parameters": {
"target": "fb.author.gender",
"threshold": 0
}
}
],
"start": 1453191346,
"end": 1453191346,
"filter": "interaction.sample <= 100"
}
"""
When I make a "POST" request to "/v1.3/pylon/analyze"
Then the response status code should be "400"
And the response body contains the JSON data
Given a mock exists
And returns error "No id was supplied." and status code "400"
When an analysis request is made with no recording id, analysisType "freqDist", parameters interval "hour" and target "fb.author.gender"
Then the analyze response status code should be "400"
And the analyze response body contains the JSON data
"""
{
"error":"No id was supplied."
Expand Down
73 changes: 69 additions & 4 deletions pylon/get.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Feature: GET /pylon/get
}
"""
When a get request is made with a recording_id "1234" and no body
Then the response status code should be "200"
And the response body contains the JSON data
Then the get response status code should be "200"
And the get response body contains the JSON data
"""
{
"id": "1234",
Expand All @@ -37,6 +37,18 @@ Feature: GET /pylon/get
}
"""

Scenario: Get without recording_id
Given a mock exists
And returns error "The recording_id must be present" and status code "400" when no query string at the path "/behat-v1.3/pylon/get"
When a get request is made without recording_id and no body
Then the get response status code should be "400"
And the get response body contains the JSON data
"""
{
"error": "The recording_id must be present"
}
"""

Scenario: Get with page and per_page
Given a mock exists
And returns this body and status code "200" when the query string "page=10&per_page=2" at the path "/behat-v1.3/pylon/get"
Expand Down Expand Up @@ -64,8 +76,8 @@ Feature: GET /pylon/get
}
"""
When a get request is made with page "10" and per_page "2" and no body
Then the response status code should be "200"
And the response body contains the JSON data
Then the get response status code should be "200"
And the get response body contains the JSON data
"""
{
"count": 1,
Expand All @@ -89,3 +101,56 @@ Feature: GET /pylon/get
]
}
"""

Scenario: Get with page
Given a mock exists
And returns this body and status code "200" when the query string "page=1" at the path "/behat-v1.3/pylon/get"
"""
{
"count": 1,
"page": 1,
"pages": 1,
"per_page": 10,
"subscriptions": [
{
"id": "some-recording-id",
"volume": 100,
"start": 12345,
"end": 12346,
"status": "running",
"name": "some random name",
"reached_capacity": false,
"identity_id": "some-identity-id",
"hash": "some-csdl-hash",
"remaining_index_capacity": 1500,
"remaining_account_capacity": 1200
}
]
}
"""
When a get request is made with page "10" and no per_page and no body
Then the get response status code should be "200"
And the get response body contains the JSON data
"""
{
"count": 1,
"page": 1,
"pages": 1,
"per_page": 10,
"subscriptions": [
{
"id": "some-recording-id",
"volume": 100,
"start": 12345,
"end": 12346,
"status": "running",
"name": "some random name",
"reached_capacity": false,
"identity_id": "some-identity-id",
"hash": "some-csdl-hash",
"remaining_index_capacity": 1500,
"remaining_account_capacity": 1200
}
]
}
"""

0 comments on commit 8761e88

Please sign in to comment.