Exemple #1
0
def test_uuid_env_var_override(mocked_session):
    """
    Test setting RP_UUID env variable overrides the rp_uuid config value
    :param mocked_session: pytest fixture
    """
    mocked_session.config.py_test_service = mock.Mock()
    mocked_session.config.option = mock.Mock()
    mocked_session.config.pluginmanager = mock.Mock()
    mocked_session.config.py_test_service.init_service = mock.Mock()
    pytest_sessionstart(mocked_session)
    args, kwargs = mocked_session.config.py_test_service.init_service.call_args
    assert kwargs.get('uuid') == 'foobar'
def test_portal_on_maintenance(mocked_session):
    """Test session configuration if RP is in maintenance mode.

    :param mocked_session: pytest fixture
    """
    mocked_session.config.option = mock.Mock()
    mocked_session.config._reporter_config = mock.Mock()
    mocked_session.config.py_test_service = mock.Mock()
    mocked_session.config.py_test_service.init_service.side_effect = \
        ResponseError("<title>Report Portal - Maintenance</title>")
    pytest_sessionstart(mocked_session)
    assert mocked_session.config.py_test_service.rp is None
def test_portal_on_maintenance(mocked_session):
    """
    Test if portal on maintenance.

    :param mocked_session: pytest fixture
    """
    mocked_session.config.py_test_service = mock.Mock()
    mocked_session.config.py_test_service.init_service.side_effect = \
        ResponseError("<title>Report Portal - Maintenance</title>")

    pytest_sessionstart(mocked_session)

    assert mocked_session.config.py_test_service.rp is None
def test_portal_on_maintenance(mocked_service_class, mocked_config,
                               mocked_session):
    """Test session configuration if RP is in maintenance mode.

    :param mocked_session: pytest fixture
    """
    mocked_config.option.rp_enabled = True
    mocked_config.option.rp_project = None

    mocked_service = mocked_service_class.return_value
    mocked_config.py_test_service = mocked_service
    mocked_service.start.side_effect = \
        ResponseError("<title>Report Portal - Maintenance</title>")
    pytest_sessionstart(mocked_session)
    assert mocked_config.py_test_service.rp is None
def test_pytest_sessionstart_with_launch_id(mocked_session):
    """Test session configuration if RP launch ID is set via command-line.

    :param mocked_session: pytest fixture
    """
    mocked_session.config.pluginmanager.hasplugin.return_value = True
    mocked_session.config._reporter_config = mock.Mock(
        spec=AgentConfig(mocked_session.config))
    mocked_session.config._reporter_config.rp_launch_attributes = []
    mocked_session.config._reporter_config.rp_launch_id = 1
    mocked_session.config.py_test_service = mock.Mock()
    pytest_sessionstart(mocked_session)
    expect(lambda: mocked_session.config.py_test_service.start_launch.
           assert_not_called())
    assert_expectations()
def test_pytest_sessionstart(mocked_wait, mocked_session):
    """Test session configuration if RP plugin is correctly configured.

    :param mocked_wait:    Mocked wait_launch function
    :param mocked_session: pytest fixture
    """
    mocked_session.config.pluginmanager.hasplugin.return_value = True
    mocked_session.config._reporter_config = mock.Mock(
        spec=AgentConfig(mocked_session.config))
    mocked_session.config._reporter_config.rp_launch_attributes = []
    mocked_session.config._reporter_config.rp_launch_id = None
    mocked_session.config.py_test_service = mock.Mock()
    pytest_sessionstart(mocked_session)
    expect(lambda: mocked_session.config.py_test_service.init_service.called)
    expect(lambda: mocked_session.config.py_test_service.rp is not None)
    expect(lambda: mocked_session.config.py_test_service.start_launch.called)
    expect(lambda: mocked_wait.called)
    assert_expectations()