Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5c79a05

Browse files
committed
Add test for relationship pointer in errors
Signed-off-by: Mehdy Khoshnoody <mehdy.khoshnoody@gmail.com>
1 parent 215e63e commit 5c79a05

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎example/tests/test_views.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,29 @@ def test_relationship_view_errors_format(self):
124124
assert "data" not in result
125125
assert "errors" in result
126126

127+
def test_relationship_view_errors_has_correct_pointers(self):
128+
url = "/comments"
129+
request_data = {
130+
"data": {
131+
"type": "comments",
132+
"attributes": {"text": "comment text"},
133+
"relationships": {
134+
"author": {"data": {"id": "INVALID_ID", "type": "authors"}}
135+
},
136+
}
137+
}
138+
response = self.client.post(url, data=request_data)
139+
assert response.status_code == 400
140+
141+
result = json.loads(response.content.decode("utf-8"))
142+
errors_source_pointer = list(
143+
map(lambda i: i["source"]["pointer"], result["errors"])
144+
)
145+
146+
assert "/data/attributes/body" in errors_source_pointer
147+
assert "/data/relationships/author" in errors_source_pointer
148+
assert "/data/relationships/entry" in errors_source_pointer
149+
127150
def test_get_empty_to_one_relationship(self):
128151
url = "/comments/{}/relationships/author".format(self.first_entry.id)
129152
response = self.client.get(url)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /