Commit 6e443d3e by Dudás Ádám

vm: is_running property for Instances

parent 9f60b684
...@@ -273,6 +273,10 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -273,6 +273,10 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
return " ".join([s for s in parts if s != ""]) return " ".join([s for s in parts if s != ""])
@property @property
def is_running(self):
return self.state == 'RUNNING'
@property
def state(self): def state(self):
"""State of the virtual machine instance. """State of the virtual machine instance.
""" """
......
from django.test import TestCase from django.test import TestCase
from mock import Mock
from ..models.common import ( from ..models.common import (
Lease Lease
...@@ -32,6 +33,13 @@ class TemplateTestCase(TestCase): ...@@ -32,6 +33,13 @@ class TemplateTestCase(TestCase):
# TODO add images & net # TODO add images & net
class InstanceTestCase(TestCase):
def test_is_running(self):
inst = Mock(state='RUNNING')
assert Instance.is_running.getter(inst)
class InterfaceTestCase(TestCase): class InterfaceTestCase(TestCase):
def test_interface_create(self): def test_interface_create(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment