Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify test unit 3par #6

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 9 additions & 29 deletions delfin/tests/unit/drivers/hpe/hpe_3par/test_hpe_3parstor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
# limitations under the License.

from unittest import TestCase, mock
import unittest

from delfin import exception
from requests import Session

from delfin import context
from delfin.common import config # noqa
from delfin import exception
from delfin.drivers.hpe.hpe_3par.alert_handler import AlertHandler
from delfin.drivers.hpe.hpe_3par.hpe_3parstor import Hpe3parStorDriver
from delfin.drivers.hpe.hpe_3par.rest_handler import RestHandler
from delfin.drivers.hpe.hpe_3par.ssh_handler import SSHHandler
from delfin.drivers.utils.rest_client import RestClient

from requests import Session


class Request:
def __init__(self):
Expand Down Expand Up @@ -161,7 +160,7 @@ def test_d_get_storage(self):
}
}
)

SSHHandler.get_health_state = mock.Mock(return_value="")
m = mock.MagicMock(status_code=200)
with mock.patch.object(RestHandler, 'call', return_value=m):
m.raise_for_status.return_value = 200
Expand Down Expand Up @@ -577,28 +576,9 @@ def test_h_parse_alert(self):
# Verify that all other fields are matching
self.assertDictEqual(expected_alert_model, alert_model)

def test_clear_alert(self):
@mock.patch.object(AlertHandler, 'clear_alert')
def test_clear_alert(self, mock_clear_alert):
driver = create_driver()
alert_id = '230584300921369'

with self.assertRaises(Exception) as exc:
driver.clear_alert(context, alert_id)
self.assertIn('Exception in SSH protocol', str(exc.exception))

"""
def test_j_restlogout(self):
m = mock.MagicMock()
with mock.patch.object(Session, 'delete', return_value=m):
m.raise_for_status.return_value = None
m.json.return_value = None
kwargs = ACCESS_INFO

rc = RestClient(**kwargs)
rh = RestHandler(rc)
re = rh.logout()
self.assertIsNone(re)
"""


if __name__ == '__main__':
unittest.main()
driver.clear_alert(context, alert_id)
self.assertEqual(mock_clear_alert.call_count, 1)