def test_sr_changemode_secondary_return(self): ''' Test sr_changemode_secondary method - return ''' mock_hana_inst = MagicMock() mock_hana = MagicMock(return_value=mock_hana_inst) with patch.object(hanamod, '_init', mock_hana): hanamod.sr_changemode_secondary('sync', 'prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') mock_hana_inst.sr_changemode_secondary.assert_called_once_with( 'sync')
def test_sr_changemode_secondary_raise(self): ''' Test sr_changemode_secondary method - raise ''' mock_hana_inst = MagicMock() mock_hana_inst.sr_changemode_secondary.side_effect = hanamod.hana.HanaError( 'hana error') mock_hana = MagicMock(return_value=mock_hana_inst) with patch.object(hanamod, '_init', mock_hana): with pytest.raises(exceptions.CommandExecutionError) as err: hanamod.sr_changemode_secondary('sync', 'prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') mock_hana_inst.sr_changemode_secondary.assert_called_once_with( 'sync') assert 'hana error' in str(err)