'Test retyping a non replicated volume.
We will test on a system that doesn\'t have replication enabled and on
one that hast it enabled.'

@ddt.data({'old_replicated': False, 'new_replicated': False}, {'old_replicated': False, 'new_replicated': True}, {'old_replicated': True, 'new_replicated': False}, {'old_replicated': True, 'new_replicated': True})
@ddt.unpack
@common_mocks
@mock.patch.object(driver.RBDDriver, '_disable_replication', return_value=mock.sentinel.disable_replication)
@mock.patch.object(driver.RBDDriver, '_enable_replication', return_value=mock.sentinel.enable_replication)
def test_retype_replicated(self, mock_disable, mock_enable, old_replicated, new_replicated):

    self.driver._is_replication_enabled = True
    replicated_type = fake_volume.fake_volume_type_obj(self.context, id=fake.VOLUME_TYPE_ID, extra_specs={'replication_enabled': '<is>    True'})
    self.volume_a.volume_type = (replicated_type if old_replicated else None)
    if new_replicated:
        new_type = replicated_type
        if old_replicated:
            update = None
        else:
            update = mock.sentinel.enable_replication
    else:
        new_type = (fake_volume.fake_volume_type_obj(self.context, id=fake.VOLUME_TYPE2_ID),)
        if old_replicated:
            update = mock.sentinel.disable_replication
        else:
            update = {'replication_status': fields.ReplicationStatus.DISABLED}
    res = self.driver.retype(self.context, self.volume_a, new_type, None, None)
    self.assertEqual((True, update), res)
