Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Ra tests #51

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ docs/_build/
target/

local.ini
test.ini
mock/
mock.sh
183 changes: 178 additions & 5 deletions example.raml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ documentation:
- title: Home
content: |
Welcome to the example API.
baseUri: http://{host}:{port}/{version}
baseUri: http://{host}:{port}/api
version: v1
mediaType: application/json
protocols: [HTTP, HTTPS]
Expand Down Expand Up @@ -65,20 +65,94 @@ securedBy: [x_ticket_auth]
body:
application/json:
schema: !include schemas/user.json
# uppercase used in email to test use of lowercase processor
example: |
{
"username": "rick",
"email": "[email protected]",
"password": "megatrees",
"first_name": "Rick"
}
responses:
201:
description: Created user
body:
application/json:
schema: !include schemas/user.json
headers:
Location:
description: The URL where the created user is available
type: string
pattern: "http.*"
example: http://localhost:6543/api/users/rick

patch:
description: Update multiple users
body:
application/json:
example: |
{ "last_name": "Sanchez" }

head:
description: Determine whether a given resource is available
options:
description: Retrieve the available HTTP verbs for a given resource

/{username}:
displayName: One user

uriParameters:
username:
type: string
maxLength: 50
example: rick

get:
description: Get a particular user
patch:
responses:
200:
body:
application/json:
schema: !include schemas/user.json

put:
description: Replace a particular user
body:
application/json:
example: |
{
"username": "morty",
"email": "[email protected]",
"first_name": "Mortimer",
"last_name": "Smith",
"password": "$2a$10$RrAZgBWzCXaBR.uM83AOg.YzYfnhxujau7JuQ2enP1ota3lgyt/9S",
"status": "active",
"profile": null,
"groups": ["user"],
"settings": {},
"stories": [],
"assigned_stories": [],
"last_login": null,
"created_at": "2015-09-11T02:13:29Z",
"updated_at": "2015-09-11T03:48:55Z"
}
responses:
200:
body:
application/json:
schema: !include schemas/user.json

patch:
description: Update a particular user
body:
application/json:
example: { "username": "rickC137" }
responses:
200:
body:
application/json:
schema: !include schemas/user.json

delete:
description: Delete a particular user

Expand All @@ -88,13 +162,19 @@ securedBy: [x_ticket_auth]
description: Get all settings of a particular user
post:
description: Change a user's settings
body:
application/json:
example: { "language": "en" }

/groups:
displayName: User groups
get:
description: Get all groups of a particular user
post:
description: Change a user's groups
body:
application/json:
example: { "admin": null }

/profile:
securedBy: [user_profile_acl]
Expand All @@ -106,21 +186,57 @@ securedBy: [x_ticket_auth]
body:
application/json:
schema: !include schemas/profile.json
example: { "address": "123 Fake St" }
responses:
200:
body:
application/json:
schema: !include schemas/profile.json
patch:
description: Update a user's profile
body:
application/json:
example: { "address": "124 Pretend Rd" }
responses:
200:
body:
application/json:
schema: !include schemas/profile.json

/stories:
securedBy: [item_owner_acl]
displayName: All stories

get:
description: Get all stories

post:
description: Create a new story
body:
application/json:
schema: !include schemas/story.json
example: |
{
"id": 1,
"owner_id": "rick",
"due_date": "2020-11-11T11:11:11Z",
"name": "do science",
"description": "real sciency stuff"
}
responses:
201:
description: Created story
body:
application/json:

schema: !include schemas/story.json

patch:
description: Update multiple stories
body:
application/json:
example: { "assignee_id": "rick" }

delete:
description: Delete multiple stories
head:
Expand All @@ -130,13 +246,70 @@ securedBy: [x_ticket_auth]

/{id}:
displayName: One story

uriParameters:
id:
description: story ID
type: integer
minimum: 1
example: 1

get:
description: Get a particular story
responses:
200:
body:
application/json:
schema: !include schemas/story.json

put:
description: Replace a particular story
body:
application/json:
example: |
{
"owner_id": "rick",
"due_date": "2020-11-11T11:11:11Z",
"name": "watch TV",
"description": "not very sciency",
"assignee_id": "rick",
"arbitrary_object": null,
"attachment": null,
"available_for": null,
"completed": false,
"created_at": "2015-09-11T05:01:27Z",
"id": 516,
"price": null,
"progress": 0.0,
"rating": null,
"reads": 0,
"signs_number": null,
"start_date": null,
"unicode_description": null,
"unicode_name": null,
"updated_at": null,
"valid_date": null,
"valid_time": null
}
responses:
200:
body:
application/json:
schemas: !include schemas/story.json

patch:
description: Update a story
body:
application/json:
example: { "completed": true }
responses:
200:
body:
application/json:
schemas: !include schemas/story.json

delete:
description: Delete a particular story
patch:
put:
description: Update a particular story
head:
description: Determine whether a given resource is available
options:
Expand Down
5 changes: 5 additions & 0 deletions local.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ system.user = system
system.password = 123456
system.email = [email protected]

# Database configuration:
#
# Note on testing: copy this template to test.ini and use a different database
# and elasticsearch index, as they will be wiped on each test run.

# SQLA
sqlalchemy.url = postgresql://localhost:5432/ramses_example

Expand Down
1 change: 1 addition & 0 deletions requirements.dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ waitress==0.8.9
-e ../nefertari-mongodb
-e ../nefertari-sqla
-e ../ramses
-e ../ra
-e .
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ nefertari==0.6.1
nefertari-mongodb==0.4.1
nefertari-sqla==0.4.1
ramses==0.5.1
ra

-e .
4 changes: 2 additions & 2 deletions schemas/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
},
"profile": {
"type": ["integer", "string"],
"type": ["integer", "string", "null"],
"_db_settings": {
"type": "relationship",
"document": "Profile",
Expand Down Expand Up @@ -160,4 +160,4 @@
}
}
}
}
}
Loading