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