@ -0,0 +1,23 @@ | |||
# Generated by Django 2.2.6 on 2019-11-27 12:40 | |||
from django.db import migrations, models | |||
class Migration(migrations.Migration): | |||
dependencies = [ | |||
('api', '0064_auto_20191119_1346'), | |||
] | |||
operations = [ | |||
migrations.AddField( | |||
model_name='check', | |||
name='methods', | |||
field=models.CharField(blank=True, max_length=30), | |||
), | |||
migrations.AlterField( | |||
model_name='channel', | |||
name='kind', | |||
field=models.CharField(choices=[('email', 'Email'), ('webhook', 'Webhook'), ('hipchat', 'HipChat'), ('slack', 'Slack'), ('pd', 'PagerDuty'), ('pagertree', 'PagerTree'), ('pagerteam', 'Pager Team'), ('po', 'Pushover'), ('pushbullet', 'Pushbullet'), ('opsgenie', 'OpsGenie'), ('victorops', 'VictorOps'), ('discord', 'Discord'), ('telegram', 'Telegram'), ('sms', 'SMS'), ('zendesk', 'Zendesk'), ('trello', 'Trello'), ('matrix', 'Matrix'), ('whatsapp', 'WhatsApp'), ('apprise', 'Apprise'), ('mattermost', 'Mattermost'), ('msteams', 'Microsoft Teams'), ('shell', 'Shell Command')], max_length=20), | |||
), | |||
] |
@ -0,0 +1,31 @@ | |||
from hc.api.models import Check | |||
from hc.test import BaseTestCase | |||
class FilteringRulesTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(FilteringRulesTestCase, self).setUp() | |||
self.check = Check.objects.create(project=self.project) | |||
self.url = "/checks/%s/filtering_rules/" % self.check.code | |||
self.redirect_url = "/checks/%s/details/" % self.check.code | |||
def test_it_works(self): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(self.url, data={"subject": "SUCCESS", "methods": "POST"}) | |||
self.assertRedirects(r, self.redirect_url) | |||
self.check.refresh_from_db() | |||
self.assertEqual(self.check.subject, "SUCCESS") | |||
self.assertEqual(self.check.methods, "POST") | |||
def test_it_clears_method(self): | |||
self.check.method = "POST" | |||
self.check.save() | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(self.url, data={"subject": "SUCCESS", "methods": ""}) | |||
self.assertRedirects(r, self.redirect_url) | |||
self.check.refresh_from_db() | |||
self.assertEqual(self.check.methods, "") |