Skip to content

Commit

Permalink
graphql: test response content type
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Dec 3, 2018
1 parent 3db6110 commit 12cd79c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion graphql_demo/tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_get(self):
data = {"query": query}
r = self.url_open("/graphql/demo?" + url_encode(data))
self.assertEqual(r.status_code, 200)
self.assertEqual(r.headers["Content-Type"], "application/json")
self._check_all_partners(r.json()["data"]["allPartners"])

def test_get_with_variables(self):
Expand All @@ -45,6 +46,7 @@ def test_get_with_variables(self):
data = {"query": query, "variables": json.dumps(variables)}
r = self.url_open("/graphql/demo?" + url_encode(data))
self.assertEqual(r.status_code, 200)
self.assertEqual(r.headers["Content-Type"], "application/json")
self._check_all_partners(
r.json()["data"]["allPartners"], companies_only=True
)
Expand All @@ -55,6 +57,7 @@ def test_post_form(self):
data = {"query": query}
r = self.url_open("/graphql/demo", data=data)
self.assertEqual(r.status_code, 200)
self.assertEqual(r.headers["Content-Type"], "application/json")
self._check_all_partners(r.json()["data"]["allPartners"])

def test_post_form_with_variables(self):
Expand Down Expand Up @@ -93,7 +96,7 @@ def test_post_json_with_variables(self):
r.json()["data"]["allPartners"], companies_only=True
)

def test_post_mutation(self):
def test_post_form_mutation(self):
self.authenticate("admin", "admin")
query = """
mutation {
Expand All @@ -107,6 +110,7 @@ def test_post_mutation(self):
data = {"query": query}
r = self.url_open("/graphql/demo", data=data)
self.assertEqual(r.status_code, 200)
self.assertEqual(r.headers["Content-Type"], "application/json")
self.assertEqual(
"Le Héro, Toto", r.json()["data"]["createPartner"]["name"]
)
Expand All @@ -128,3 +132,5 @@ def test_get_mutation_not_allowed(self):
data = {"query": query}
r = self.url_open("/graphql/demo?" + url_encode(data))
self.assertEqual(r.status_code, 405)
self.assertEqual(r.headers["Content-Type"], "application/json")
self.assertIn(

0 comments on commit 12cd79c

Please sign in to comment.