mirror of
https://github.com/status-im/cabot.git
synced 2025-02-24 10:28:06 +00:00
Some tweaks
This commit is contained in:
parent
81c107c5ec
commit
a318477d28
@ -262,7 +262,7 @@ class Instance(CheckGroupMixin):
|
||||
new_instance.save()
|
||||
|
||||
for check in checks:
|
||||
check.duplicate(inst_set=[new_instance], serv_set=())
|
||||
check.duplicate(inst_set=(new_instance,), serv_set=())
|
||||
|
||||
return new_instance.pk
|
||||
|
||||
@ -491,10 +491,11 @@ class StatusCheck(PolymorphicModel):
|
||||
new_check = self
|
||||
new_check.pk = None
|
||||
new_check.id = None
|
||||
new_check.last_run = None
|
||||
new_check.save()
|
||||
if inst_set is not None:
|
||||
if inst_set:
|
||||
new_check.instance_set.add(*inst_set)
|
||||
if serv_set is not None:
|
||||
if serv_set:
|
||||
new_check.service_set.add(*serv_set)
|
||||
return new_check.pk
|
||||
|
||||
|
@ -266,6 +266,22 @@ class TestCheckRun(LocalTestCase):
|
||||
Service.CALCULATED_FAILING_STATUS)
|
||||
|
||||
|
||||
class TestInstances(LocalTestCase):
|
||||
|
||||
def test_duplicate_instance(self):
|
||||
instances = Instance.objects.all()
|
||||
self.assertEqual(len(instances), 0)
|
||||
self.instance = Instance.objects.create(
|
||||
name='Hello',
|
||||
address='192.168.0.1',
|
||||
)
|
||||
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')
|
||||
|
||||
|
||||
class TestWebInterface(LocalTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user