Revision 278f2eb3 kamaki/clients/test/cyclades.py

b/kamaki/clients/test/cyclades.py
428 428
                self.client.get_firewall_profile,
429 429
                vm_id)
430 430

  
431
    """
432 431
    def test_set_firewall_profile(self):
433
        self._wait_for_status(self.server1['id'], 'BUILD')
434
        PROFILES = ['DISABLED', 'ENABLED', 'DISABLED', 'PROTECTED']
435
        fprofile = self.client.get_firewall_profile(self.server1['id'])
436
        print('')
437
        count_success = 0
438
        for counter, fprofile in enumerate(PROFILES):
439
            npos = counter + 1
440
            try:
441
                nprofile = PROFILES[npos]
442
            except IndexError:
443
                nprofile = PROFILES[0]
444
            print('\tprofile swap %s: %s -> %s' % (npos, fprofile, nprofile))
445
            self.client.set_firewall_profile(self.server1['id'], nprofile)
446
            time.sleep(0.5)
447
            self.client.reboot_server(self.server1['id'], hard=True)
448
            time.sleep(1)
449
            self._wait_for_status(self.server1['id'], 'REBOOT')
450
            time.sleep(0.5)
451
            changed = self.client.get_firewall_profile(self.server1['id'])
452
            try:
453
                self.assertEqual(changed, nprofile)
454
            except AssertionError as err:
455
                if count_success:
456
                    print('\tFAIL in swap #%s' % npos)
457
                    break
458
                else:
459
                    raise err
460
            count_success += 1
432
        vm_id = vm_recv['server']['id']
433
        v = 'Some profile'
434
        self.FR.status_code = 202
435
        with patch.object(
436
                self.C,
437
                'perform_request',
438
                return_value=self.FR()) as perform_req:
439
            self.client.set_firewall_profile(vm_id, v)
440
            self.assertEqual(self.client.http_client.url, self.url)
441
            self.assertEqual(
442
                self.client.http_client.path,
443
                '/servers/%s/action' % vm_id)
444
            self.assertEqual(perform_req.call_args[0], (
445
                'post',
446
                '{"firewallProfile": {"profile": "%s"}}' % v,
447
                {},
448
                {}))
461 449

  
450
    """
462 451
    def test_get_server_stats(self):
463 452
        r = self.client.get_server_stats(self.server1['id'])
464 453
        it = ('cpuBar', 'cpuTimeSeries', 'netBar', 'netTimeSeries', 'refresh')

Also available in: Unified diff