def test_login_command__load_from_context(mocker): """ Scenario: test successful login command attempt with load from the context Given: - User has provided valid credentials - Integration context has a previous session When: - zscaler-login command is called Then: - Ensure logout is called - Ensure login is called - Ensure readable output is as expected """ import Zscaler mocker.patch.object(demisto, 'debug') mocker.patch.object(Zscaler, 'get_integration_context', return_value={Zscaler.SESSION_ID_KEY: 'test_key'}) logout_mock = mocker.patch.object(Zscaler, 'logout') login_mock = mocker.patch.object(Zscaler, 'login') raw_res = Zscaler.login_command() assert logout_mock.called assert login_mock.called assert raw_res.readable_output == 'Zscaler session created successfully.'
def test_login_command(mocker): """ Scenario: test successful login command Given: - User provided valid credentials - Integration context is empty When: - zscaler-login command is called Then: - Ensure logout is not called - Ensure login is called - Ensure readable output is as expected """ import Zscaler mocker.patch.object(demisto, 'debug') mocker.patch.object(Zscaler, 'get_integration_context', return_value={}) logout_mock = mocker.patch.object(Zscaler, 'logout') login_mock = mocker.patch.object(Zscaler, 'login') raw_res = Zscaler.login_command() assert not logout_mock.called assert login_mock.called assert raw_res.readable_output == 'Zscaler session created successfully.'