def test_sr_register_secondary_return(self): ''' Test sr_register_secondary method - return ''' mock_hana_inst = MagicMock() mock_hana = MagicMock(return_value=mock_hana_inst) with patch.object(hanamod, '_init', mock_hana): hanamod.sr_register_secondary('PRAGUE', 'hana01', '00', 'sync', 'logreplay', 'prd', '00', 'pass', primary_pass='******', timeout=10, interval=10) mock_hana.assert_called_once_with('prd', '00', 'pass') mock_hana_inst.sr_register_secondary.assert_called_once_with( 'PRAGUE', 'hana01', '00', 'sync', 'logreplay', primary_pass='******', timeout=10, interval=10)
def test_sr_register_secondary_raise(self): ''' Test sr_register_secondary method - raise ''' mock_hana_inst = MagicMock() mock_hana_inst.sr_register_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_register_secondary('PRAGUE', 'hana01', '00', 'sync', 'logreplay', 'prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') mock_hana_inst.sr_register_secondary.assert_called_once_with( 'PRAGUE', 'hana01', '00', 'sync', 'logreplay') assert 'hana error' in str(err)