2018-08-19 15:08:57 +00:00
|
|
|
from hc.api.models import Check, Ping
|
|
|
|
from hc.test import BaseTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class DetailsTestCase(BaseTestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(DetailsTestCase, self).setUp()
|
2019-01-18 15:24:02 +00:00
|
|
|
self.check = Check.objects.create(project=self.project)
|
2018-08-19 15:08:57 +00:00
|
|
|
|
2019-01-18 15:24:02 +00:00
|
|
|
ping = Ping.objects.create(owner=self.check)
|
2018-08-19 15:08:57 +00:00
|
|
|
|
|
|
|
# Older MySQL versions don't store microseconds. This makes sure
|
|
|
|
# the ping is older than any notifications we may create later:
|
|
|
|
ping.created = "2000-01-01T00:00:00+00:00"
|
|
|
|
ping.save()
|
|
|
|
|
|
|
|
self.url = "/checks/%s/details/" % self.check.code
|
|
|
|
|
|
|
|
def test_it_works(self):
|
|
|
|
self.client.login(username="alice@example.org", password="password")
|
|
|
|
r = self.client.get(self.url)
|
|
|
|
self.assertContains(r, "How To Ping", status_code=200)
|
2018-10-02 11:37:58 +00:00
|
|
|
# The page should contain timezone strings
|
|
|
|
self.assertContains(r, "Europe/Riga")
|
2018-08-19 15:08:57 +00:00
|
|
|
|
|
|
|
def test_it_checks_ownership(self):
|
|
|
|
self.client.login(username="charlie@example.org", password="password")
|
|
|
|
r = self.client.get(self.url)
|
2018-11-29 11:51:25 +00:00
|
|
|
self.assertEqual(r.status_code, 404)
|
2018-08-19 15:08:57 +00:00
|
|
|
|
|
|
|
def test_it_shows_cron_expression(self):
|
|
|
|
self.check.kind = "cron"
|
|
|
|
self.check.save()
|
|
|
|
|
|
|
|
self.client.login(username="alice@example.org", password="password")
|
|
|
|
r = self.client.get(self.url)
|
|
|
|
self.assertContains(r, "Cron Expression", status_code=200)
|
2018-11-29 11:51:25 +00:00
|
|
|
|
|
|
|
def test_it_allows_cross_team_access(self):
|
|
|
|
self.client.login(username="bob@example.org", password="password")
|
|
|
|
r = self.client.get(self.url)
|
|
|
|
self.assertEqual(r.status_code, 200)
|
2019-08-27 13:03:06 +00:00
|
|
|
|
|
|
|
def test_it_shows_new_check_notice(self):
|
|
|
|
self.client.login(username="alice@example.org", password="password")
|
|
|
|
r = self.client.get(self.url + "?new")
|
|
|
|
self.assertContains(r, "Your new check is ready!", status_code=200)
|
2020-08-26 09:16:43 +00:00
|
|
|
|
|
|
|
def test_it_hides_actions_from_readonly_users(self):
|
|
|
|
self.bobs_membership.rw = False
|
|
|
|
self.bobs_membership.save()
|
|
|
|
|
|
|
|
self.client.login(username="bob@example.org", password="password")
|
|
|
|
r = self.client.get(self.url)
|
|
|
|
|
|
|
|
self.assertNotContains(r, "edit-name", status_code=200)
|
|
|
|
self.assertNotContains(r, "edit-desc")
|
2020-08-26 09:36:05 +00:00
|
|
|
self.assertNotContains(r, "Filtering Rules")
|
2020-08-26 09:29:03 +00:00
|
|
|
self.assertNotContains(r, "pause-btn")
|
2020-08-26 09:16:43 +00:00
|
|
|
self.assertNotContains(r, "Change Schedule")
|