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

b/snf-cyclades-app/synnefo/logic/tests.py
41 41
from datetime import datetime
42 42
from mock import patch
43 43
from synnefo.api.util import allocate_resource
44
from synnefo.logic.callbacks import (update_db, update_net, update_network,
44
from synnefo.logic.callbacks import (update_db, update_network,
45 45
                                     update_build_progress)
46 46
from snf_django.utils.testing import mocked_quotaholder
47 47

  
......
199 199
    def create_msg(self, **kwargs):
200 200
        """Create snf-ganeti-hook message"""
201 201
        msg = {'event_time': split_time(time())}
202
        msg['type'] = 'ganeti-net-status'
202
        msg['type'] = 'ganeti-op-status'
203
        msg['operation'] = 'OP_INSTANCE_SET_PARAMS'
203 204
        msg['status'] = 'success'
204 205
        msg['jobId'] = 1
205 206
        msg['logmsg'] = 'Dummy Log'
......
209 210
        return message
210 211

  
211 212
    def test_missing_attribute(self, client):
212
        update_net(client, json.dumps({'body': {}}))
213
        update_db(client, json.dumps({'body': {}}))
213 214
        client.basic_nack.assert_called_once()
214 215

  
215 216
    def test_unhandled_exception(self, client):
216
        update_net(client, {})
217
        update_db(client, {})
217 218
        client.basic_reject.assert_called_once()
218 219

  
219 220
    def test_wrong_type(self, client):
220 221
        msg = self.create_msg(type="WRONG_TYPE")
221
        update_net(client, msg)
222
        update_db(client, msg)
222 223
        client.basic_ack.assert_called_once()
223 224

  
224 225
    def test_missing_instance(self, client):
225 226
        msg = self.create_msg(operation='OP_INSTANCE_STARTUP',
226 227
                              instance='foo')
227
        update_net(client, msg)
228
        update_db(client, msg)
228 229
        client.basic_nack.assert_called_once()
229 230

  
230 231
    def test_no_nics(self, client):
......
235 236
        self.assertEqual(len(vm.nics.all()), 3)
236 237
        msg = self.create_msg(nics=[],
237 238
                              instance=vm.backend_vm_id)
238
        update_net(client, msg)
239
        update_db(client, msg)
239 240
        client.basic_ack.assert_called_once()
240 241
        db_vm = VirtualMachine.objects.get(id=vm.id)
241 242
        self.assertEqual(len(db_vm.nics.all()), 0)
......
246 247
            net = mfactory.NetworkFactory(public=public)
247 248
            msg = self.create_msg(nics=[{'network': net.backend_id}],
248 249
                                  instance=vm.backend_vm_id)
249
            update_net(client, msg)
250
            update_db(client, msg)
250 251
            client.basic_ack.assert_called_once()
251 252
            db_vm = VirtualMachine.objects.get(id=vm.id)
252 253
            nics = db_vm.nics.all()
......
271 272
                                     'ip': '10.0.0.22',
272 273
                                     'mac': 'aa:bb:cc:00:11:22'}],
273 274
                              instance=vm.backend_vm_id)
274
        update_net(client, msg)
275
        update_db(client, msg)
275 276
        client.basic_ack.assert_called_once()
276 277
        db_vm = VirtualMachine.objects.get(id=vm.id)
277 278
        nics = db_vm.nics.all()

Also available in: Unified diff