Ejemplo n.º 1
0
 def test_get_sr_state_raise(self):
     '''
     Test get_sr_state method - raise
     '''
     mock_hana_inst = MagicMock()
     mock_hana_inst.get_sr_state.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.get_sr_state('prd', '00', 'pass')
         mock_hana.assert_called_once_with('prd', '00', 'pass')
         mock_hana_inst.get_sr_state.assert_called_once_with()
         assert 'hana error' in str(err)
Ejemplo n.º 2
0
 def test_get_sr_state_return(self):
     '''
     Test get_sr_state method - return
     '''
     mock_hana_inst = MagicMock()
     mock_hana_inst.get_sr_state.return_value = 1
     mock_hana = MagicMock(return_value=mock_hana_inst)
     with patch.object(hanamod, '_init', mock_hana):
         assert 1 == hanamod.get_sr_state('prd', '00', 'pass')
         mock_hana.assert_called_once_with('prd', '00', 'pass')
         mock_hana_inst.get_sr_state.assert_called_once_with()