def test_sr_disable_primary_return(self): ''' Test sr_disable_primary method - return ''' mock_hana_inst = MagicMock() mock_hana = MagicMock(return_value=mock_hana_inst) with patch.object(hanamod, '_init', mock_hana): hanamod.sr_disable_primary('prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') mock_hana_inst.sr_disable_primary.assert_called_once_with()
def test_sr_disable_primary_raise(self): ''' Test sr_disable_primary method - raise ''' mock_hana_inst = MagicMock() mock_hana_inst.sr_disable_primary.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_disable_primary('prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') mock_hana_inst.sr_disable_primary.assert_called_once_with() assert 'hana error' in str(err)