forked from GithubBackups/healthchecks
Sorting keys on Webhook JSON value for consistent unit testing.
This commit is contained in:
parent
05c84d7976
commit
077bc45b12
@ -69,7 +69,7 @@ class AddWebhookForm(forms.Form):
|
|||||||
headers = forms.CharField(max_length=1000, required=False)
|
headers = forms.CharField(max_length=1000, required=False)
|
||||||
|
|
||||||
def get_value(self):
|
def get_value(self):
|
||||||
return json.dumps(self.cleaned_data)
|
return json.dumps(self.cleaned_data, sort_keys=True)
|
||||||
|
|
||||||
|
|
||||||
phone_validator = RegexValidator(regex='^\+\d{5,15}$',
|
phone_validator = RegexValidator(regex='^\+\d{5,15}$',
|
||||||
|
@ -18,7 +18,7 @@ class AddWebhookTestCase(BaseTestCase):
|
|||||||
self.assertRedirects(r, "/integrations/")
|
self.assertRedirects(r, "/integrations/")
|
||||||
|
|
||||||
c = Channel.objects.get()
|
c = Channel.objects.get()
|
||||||
self.assertEqual(c.value, '{"url_down": "http://foo.com", "url_up": "https://bar.com", "post_data": "", "headers": ""}')
|
self.assertEqual(c.value, '{"headers": "", "post_data": "", "url_down": "http://foo.com", "url_up": "https://bar.com"}')
|
||||||
|
|
||||||
def test_it_adds_webhook_using_team_access(self):
|
def test_it_adds_webhook_using_team_access(self):
|
||||||
form = {"url_down": "http://foo.com", "url_up": "https://bar.com"}
|
form = {"url_down": "http://foo.com", "url_up": "https://bar.com"}
|
||||||
@ -30,7 +30,7 @@ class AddWebhookTestCase(BaseTestCase):
|
|||||||
|
|
||||||
c = Channel.objects.get()
|
c = Channel.objects.get()
|
||||||
self.assertEqual(c.user, self.alice)
|
self.assertEqual(c.user, self.alice)
|
||||||
self.assertEqual(c.value, '{"url_down": "http://foo.com", "url_up": "https://bar.com", "post_data": "", "headers": ""}')
|
self.assertEqual(c.value, '{"headers": "", "post_data": "", "url_down": "http://foo.com", "url_up": "https://bar.com"}')
|
||||||
|
|
||||||
def test_it_rejects_bad_urls(self):
|
def test_it_rejects_bad_urls(self):
|
||||||
urls = [
|
urls = [
|
||||||
@ -59,7 +59,7 @@ class AddWebhookTestCase(BaseTestCase):
|
|||||||
self.client.post(self.url, form)
|
self.client.post(self.url, form)
|
||||||
|
|
||||||
c = Channel.objects.get()
|
c = Channel.objects.get()
|
||||||
self.assertEqual(c.value, '{"url_down": "", "url_up": "http://foo.com", "post_data": "", "headers": ""}')
|
self.assertEqual(c.value, '{"headers": "", "post_data": "", "url_down": "", "url_up": "http://foo.com"}')
|
||||||
|
|
||||||
def test_it_adds_post_data(self):
|
def test_it_adds_post_data(self):
|
||||||
form = {"url_down": "http://foo.com", "post_data": "hello"}
|
form = {"url_down": "http://foo.com", "post_data": "hello"}
|
||||||
@ -69,7 +69,7 @@ class AddWebhookTestCase(BaseTestCase):
|
|||||||
self.assertRedirects(r, "/integrations/")
|
self.assertRedirects(r, "/integrations/")
|
||||||
|
|
||||||
c = Channel.objects.get()
|
c = Channel.objects.get()
|
||||||
self.assertEqual(c.value, '{"url_down": "http://foo.com", "url_up": "", "post_data": "hello", "headers": ""}')
|
self.assertEqual(c.value, '{"headers": "", "post_data": "hello", "url_down": "http://foo.com", "url_up": ""}')
|
||||||
|
|
||||||
def test_it_adds_headers(self):
|
def test_it_adds_headers(self):
|
||||||
form = {"url_down": "http://foo.com", "headers": '{"test": "123"}'}
|
form = {"url_down": "http://foo.com", "headers": '{"test": "123"}'}
|
||||||
@ -79,5 +79,5 @@ class AddWebhookTestCase(BaseTestCase):
|
|||||||
self.assertRedirects(r, "/integrations/")
|
self.assertRedirects(r, "/integrations/")
|
||||||
|
|
||||||
c = Channel.objects.get()
|
c = Channel.objects.get()
|
||||||
self.assertEqual(c.value, '{"url_down": "http://foo.com", "url_up": "", "post_data": "", "headers": "{\\\"test\\\": \\\"123\\\"}"}')
|
self.assertEqual(c.value, '{"headers": "{\\\"test\\\": \\\"123\\\"}", "post_data": "", "url_down": "http://foo.com", "url_up": ""}')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user