コード例 #1
0
 def test_sr_cleanup_return(self):
     '''
     Test sr_cleanup method - return
     '''
     mock_hana_inst = MagicMock()
     mock_hana = MagicMock(return_value=mock_hana_inst)
     with patch.object(hanamod, '_init', mock_hana):
         hanamod.sr_cleanup(True, 'prd', '00', 'pass')
         mock_hana.assert_called_once_with('prd', '00', 'pass')
         mock_hana_inst.sr_cleanup.assert_called_once_with(True)
コード例 #2
0
 def test_sr_cleanup_raise(self):
     '''
     Test sr_cleanup method - raise
     '''
     mock_hana_inst = MagicMock()
     mock_hana_inst.sr_cleanup.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_cleanup(False, 'prd', '00', 'pass')
         mock_hana.assert_called_once_with('prd', '00', 'pass')
         mock_hana_inst.sr_cleanup.assert_called_once_with(False)
         assert 'hana error' in str(err)