mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +00:00 
			
		
		
		
	use constant for content type
This commit is contained in:
		| @@ -10,6 +10,8 @@ from django.contrib.auth import get_user_model | |||||||
| from .models import InvenTreeSetting, WebhookEndpoint, WebhookMessage, NotificationEntry | from .models import InvenTreeSetting, WebhookEndpoint, WebhookMessage, NotificationEntry | ||||||
| from .api import WebhookView | from .api import WebhookView | ||||||
|  |  | ||||||
|  | CONTENT_TYPE_JSON = 'application/json' | ||||||
|  |  | ||||||
|  |  | ||||||
| class SettingsTest(TestCase): | class SettingsTest(TestCase): | ||||||
|     """ |     """ | ||||||
| @@ -105,7 +107,7 @@ class WebhookMessageTests(TestCase): | |||||||
|     def test_missing_token(self): |     def test_missing_token(self): | ||||||
|         response = self.client.post( |         response = self.client.post( | ||||||
|             self.url, |             self.url, | ||||||
|             content_type='application/json', |             content_type=CONTENT_TYPE_JSON, | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         assert response.status_code == HTTPStatus.FORBIDDEN |         assert response.status_code == HTTPStatus.FORBIDDEN | ||||||
| @@ -116,7 +118,7 @@ class WebhookMessageTests(TestCase): | |||||||
|     def test_bad_token(self): |     def test_bad_token(self): | ||||||
|         response = self.client.post( |         response = self.client.post( | ||||||
|             self.url, |             self.url, | ||||||
|             content_type='application/json', |             content_type=CONTENT_TYPE_JSON, | ||||||
|             **{'HTTP_TOKEN': '1234567fghj'}, |             **{'HTTP_TOKEN': '1234567fghj'}, | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -126,7 +128,7 @@ class WebhookMessageTests(TestCase): | |||||||
|     def test_bad_url(self): |     def test_bad_url(self): | ||||||
|         response = self.client.post( |         response = self.client.post( | ||||||
|             '/api/webhook/1234/', |             '/api/webhook/1234/', | ||||||
|             content_type='application/json', |             content_type=CONTENT_TYPE_JSON, | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         assert response.status_code == HTTPStatus.NOT_FOUND |         assert response.status_code == HTTPStatus.NOT_FOUND | ||||||
| @@ -135,7 +137,7 @@ class WebhookMessageTests(TestCase): | |||||||
|         response = self.client.post( |         response = self.client.post( | ||||||
|             self.url, |             self.url, | ||||||
|             data="{'this': 123}", |             data="{'this': 123}", | ||||||
|             content_type='application/json', |             content_type=CONTENT_TYPE_JSON, | ||||||
|             **{'HTTP_TOKEN': str(self.endpoint_def.token)}, |             **{'HTTP_TOKEN': str(self.endpoint_def.token)}, | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -152,7 +154,7 @@ class WebhookMessageTests(TestCase): | |||||||
|         # check |         # check | ||||||
|         response = self.client.post( |         response = self.client.post( | ||||||
|             self.url, |             self.url, | ||||||
|             content_type='application/json', |             content_type=CONTENT_TYPE_JSON, | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         assert response.status_code == HTTPStatus.OK |         assert response.status_code == HTTPStatus.OK | ||||||
| @@ -167,7 +169,7 @@ class WebhookMessageTests(TestCase): | |||||||
|         # check |         # check | ||||||
|         response = self.client.post( |         response = self.client.post( | ||||||
|             self.url, |             self.url, | ||||||
|             content_type='application/json', |             content_type=CONTENT_TYPE_JSON, | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         assert response.status_code == HTTPStatus.FORBIDDEN |         assert response.status_code == HTTPStatus.FORBIDDEN | ||||||
| @@ -182,7 +184,7 @@ class WebhookMessageTests(TestCase): | |||||||
|         # check |         # check | ||||||
|         response = self.client.post( |         response = self.client.post( | ||||||
|             self.url, |             self.url, | ||||||
|             content_type='application/json', |             content_type=CONTENT_TYPE_JSON, | ||||||
|             **{'HTTP_TOKEN': str('68MXtc/OiXdA5e2Nq9hATEVrZFpLb3Zb0oau7n8s31I=')}, |             **{'HTTP_TOKEN': str('68MXtc/OiXdA5e2Nq9hATEVrZFpLb3Zb0oau7n8s31I=')}, | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -193,7 +195,7 @@ class WebhookMessageTests(TestCase): | |||||||
|         response = self.client.post( |         response = self.client.post( | ||||||
|             self.url, |             self.url, | ||||||
|             data={"this": "is a message"}, |             data={"this": "is a message"}, | ||||||
|             content_type='application/json', |             content_type=CONTENT_TYPE_JSON, | ||||||
|             **{'HTTP_TOKEN': str(self.endpoint_def.token)}, |             **{'HTTP_TOKEN': str(self.endpoint_def.token)}, | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user