Update tests

This commit is contained in:
David Buxton 2014-08-05 08:40:32 +01:00
parent a318477d28
commit 2e53658469
2 changed files with 12 additions and 5 deletions

View File

@ -257,7 +257,7 @@ class Instance(CheckGroupMixin):
new_instance = self
new_instance.pk = None
new_instance.id = None
new_instance.name = "Copy of %s" % self.name
new_instance.name = u"Copy of %s" % self.name
new_instance.save()
@ -493,10 +493,8 @@ class StatusCheck(PolymorphicModel):
new_check.id = None
new_check.last_run = None
new_check.save()
if inst_set:
new_check.instance_set.add(*inst_set)
if serv_set:
new_check.service_set.add(*serv_set)
for linked in list(inst_set) + list(serv_set):
linked.status_checks.add(new_check)
return new_check.pk
def update_related_services(self):

View File

@ -275,11 +275,19 @@ class TestInstances(LocalTestCase):
name='Hello',
address='192.168.0.1',
)
pingcheck = ICMPStatusCheck.objects.create(
name='Hello check',
)
self.instance.status_checks.add(pingcheck)
self.instance.duplicate()
instances = Instance.objects.all()
self.assertEqual(len(instances), 2)
new = instances.filter(name__icontains='Copy of')[0]
self.assertEqual(new.name, 'Copy of Hello')
old = instances.exclude(name__icontains='Copy of')[0]
self.assertEqual(len(new.status_checks.all()), 1)
self.assertEqual(len(old.status_checks.all()), 1)
self.assertNotEqual(new.status_checks.all()[0], old.status_checks.all()[0])
class TestWebInterface(LocalTestCase):
@ -358,3 +366,4 @@ class TestWebInterface(LocalTestCase):
check = checks[0]
self.assertEqual(len(check.problems), 1)
self.assertEqual(check.success_rate, 50)