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