Revision b66e4833 snf-cyclades-app/synnefo/logic/tests.py

b/snf-cyclades-app/synnefo/logic/tests.py
84 84
        update_db(client, msg)
85 85
        client.basic_ack.assert_called_once()
86 86

  
87
    def test_old_msg(self, client):
88
        from time import sleep
89
        from datetime import datetime
90
        old_time = time()
91
        sleep(0.01)
92
        new_time = datetime.fromtimestamp(time())
93
        vm = mfactory.VirtualMachineFactory(backendtime=new_time)
94
        vm.operstate = 'STOPPED'
95
        vm.save()
96
        msg = self.create_msg(operation='OP_INSTANCE_STARTUP',
97
                              event_time=split_time(old_time),
98
                              instance=vm.backend_vm_id)
99
        update_db(client, msg)
100
        client.basic_ack.assert_called_once()
101
        db_vm = VirtualMachine.objects.get(id=vm.id)
102
        self.assertEquals(db_vm.operstate, "STOPPED")
103
        self.assertEquals(db_vm.backendtime, new_time)
104

  
87 105
    def test_start(self, client):
88 106
        vm = mfactory.VirtualMachineFactory()
89 107
        msg = self.create_msg(operation='OP_INSTANCE_STARTUP',
......
541 559
                          set([(2, 'STARTED', False),
542 560
                           (3, 'BUILD', True), (4, 'STARTED', False),
543 561
                           (50, 'BUILD', True)]))
562

  
563
from synnefo.logic.test.rapi_pool_tests import *
564
from synnefo.logic.test.utils_tests import *

Also available in: Unified diff