|
4 | 4 |
|
5 | 5 | :license: MIT, see LICENSE for more details.
|
6 | 6 | """
|
7 |
| -from SoftLayer import exceptions |
| 7 | +from SoftLayer import SoftLayerAPIError |
8 | 8 | from SoftLayer import testing
|
| 9 | +from SoftLayer.CLI import exceptions |
9 | 10 |
|
10 | 11 | import json
|
11 | 12 | import mock
|
@@ -48,7 +49,7 @@ def test_volume_set_lun_id_in_range_missing_value(self):
|
48 | 49 | def test_volume_set_lun_id_not_in_range(self):
|
49 | 50 | value = '-1'
|
50 | 51 | lun_mock = self.set_mock('SoftLayer_Network_Storage', 'createOrUpdateLunId')
|
51 |
| - lun_mock.side_effect = exceptions.SoftLayerAPIError( |
| 52 | + lun_mock.side_effect = SoftLayerAPIError( |
52 | 53 | 'SoftLayer_Exception_Network_Storage_Iscsi_InvalidLunId',
|
53 | 54 | 'The LUN ID specified is out of the valid range: %s [min: 0 max: 4095]' % (value))
|
54 | 55 | result = self.run_command('block volume-set-lun-id 1234 42'.split())
|
@@ -498,6 +499,18 @@ def test_replicant_failover(self):
|
498 | 499 | self.assert_no_fail(result)
|
499 | 500 | self.assertEqual('Failover to replicant is now in progress.\n',
|
500 | 501 | result.output)
|
| 502 | + |
| 503 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 504 | + @mock.patch('SoftLayer.BlockStorageManager.disaster_recovery_failover_to_replicant') |
| 505 | + def test_disaster_recovery_failover(self, disaster_recovery_failover_mock, confirm_mock): |
| 506 | + confirm_mock.return_value = True |
| 507 | + disaster_recovery_failover_mock.return_value = True |
| 508 | + result = self.run_command(['block', 'disaster-recovery-failover', '12345678', |
| 509 | + '--replicant-id=5678']) |
| 510 | + |
| 511 | + self.assert_no_fail(result) |
| 512 | + self.assertIn('Disaster Recovery Failover to replicant is now in progress.\n', |
| 513 | + result.output) |
501 | 514 |
|
502 | 515 | def test_replication_locations(self):
|
503 | 516 | result = self.run_command(['block', 'replica-locations', '1234'])
|
@@ -558,6 +571,28 @@ def test_replicant_failover_unsuccessful(self, failover_mock):
|
558 | 571 | self.assertEqual('Failover operation could not be initiated.\n',
|
559 | 572 | result.output)
|
560 | 573 |
|
| 574 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 575 | + @mock.patch('SoftLayer.BlockStorageManager.disaster_recovery_failover_to_replicant') |
| 576 | + def test_disaster_recovery_failover_unsuccesful(self, disaster_recovery_failover_mock, confirm_mock): |
| 577 | + confirm_mock.return_value = True |
| 578 | + disaster_recovery_failover_mock.return_value = False |
| 579 | + |
| 580 | + result = self.run_command(['block', 'disaster-recovery-failover', '12345678', |
| 581 | + '--replicant-id=5678']) |
| 582 | + |
| 583 | + self.assertIn('Disaster Recovery Failover operation could not be initiated.\n', |
| 584 | + result.output) |
| 585 | + |
| 586 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 587 | + def test_disaster_recovery_failover_aborted(self, confirm_mock): |
| 588 | + confirm_mock.return_value = False |
| 589 | + |
| 590 | + result = self.run_command(['block', 'disaster-recovery-failover', '12345678', |
| 591 | + '--replicant-id=5678']) |
| 592 | + |
| 593 | + self.assertEqual(result.exit_code, 2) |
| 594 | + self.assertIsInstance(result.exception, exceptions.CLIAbort) |
| 595 | + |
561 | 596 | def test_replicant_failback(self):
|
562 | 597 | result = self.run_command(['block', 'replica-failback', '12345678'])
|
563 | 598 |
|
|
0 commit comments