Skip to content

Commit

Permalink
Merge pull request #44 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth authored Oct 24, 2023
2 parents da93e83 + cc526f9 commit 727d2d6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## [Unreleased]
### Changed
- Improve Scenario Outline parameters reporting, by @nicke46

## [4.0.1]
### Added
- Scenario Outline scenarios will add markdown table with active params to scenario description, by @nicke46

Expand Down
16 changes: 5 additions & 11 deletions behave_reportportal/behave_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def start_scenario(self, context, scenario, **kwargs):
parent_item_id=self._feature_id,
code_ref=self._code_ref(scenario),
attributes=self._attributes(scenario),
parameters=self._get_parameters(scenario),
parameters=self._get_parameters(context),
description=self._item_description(context, scenario),
test_case_id=self._test_case_id(scenario),
**kwargs,
Expand Down Expand Up @@ -413,16 +413,10 @@ def _item_description(context, item):
return desc

@staticmethod
def _get_parameters(scenario):
# noinspection PyProtectedMember
return (
scenario._row
and {
r[0]: r[1]
for r in zip(scenario._row.headings, scenario._row.cells)
}
or None
)
def _get_parameters(context):
if context.active_outline:
return {r[0]: r[1] for r in zip(context.active_outline.headings, context.active_outline.cells)}
return None

@staticmethod
def _code_ref(item):
Expand Down
2 changes: 1 addition & 1 deletion behave_reportportal/behave_agent.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ class BehaveAgent:
def _code_ref(item: BasicStatement) -> Optional[str]: ...

@staticmethod
def _get_parameters(scenario: Scenario) -> Optional[
def _get_parameters(context: Context) -> Optional[
Dict[str, Any]]: ...
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from setuptools import setup

__version__ = '4.0.1'
__version__ = '4.0.2'


def read_file(fname):
Expand Down
3 changes: 1 addition & 2 deletions tests/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
def before_all(context):
cfg = read_config(context)
context.rp_client = create_rp_service(cfg)
context.rp_client.start()
context.rp_agent = BehaveAgent(cfg, context.rp_client)
context.rp_agent.start_launch(context)


def after_all(context):
context.rp_agent.finish_launch(context)
context.rp_client.terminate()
context.rp_client.close()


def before_feature(context, feature):
Expand Down
19 changes: 9 additions & 10 deletions tests/units/test_rp_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,19 @@ def test_code_ref():


def test_get_parameters():
mock_item = mock.Mock()
mock_item._row = None
mock_context = mock.Mock()
mock_context.active_outline = None
expect(
BehaveAgent._get_parameters(mock_item) is None,
BehaveAgent._get_parameters(mock_context) is None,
"parameters is not None",
)
mock_row = mock.Mock()
mock_row.headings = ["A", "B"]
mock_row.cells = [1, 2]
mock_item._row = mock_row
mock_context.active_outline = mock.Mock()
mock_context.active_outline.headings = ["A", "B"]
mock_context.active_outline.cells = [1, 2]
expect(
BehaveAgent._get_parameters(mock_item) == {"A": 1, "B": 2},
BehaveAgent._get_parameters(mock_context) == {"A": 1, "B": 2},
f"parameters are incorrect:\n"
f"Actual: {BehaveAgent._get_parameters(mock_item)}\n"
f"Actual: {BehaveAgent._get_parameters(mock_context)}\n"
f"Expected: {{'A': 1, 'B': 2}}",
)
assert_expectations()
Expand Down Expand Up @@ -467,7 +466,7 @@ def verify_start_scenario(mock_scenario, config):
parent_item_id="feature_id",
description=BehaveAgent._item_description(mock_context, mock_scenario),
code_ref=BehaveAgent._code_ref(mock_scenario),
parameters=BehaveAgent._get_parameters(mock_scenario),
parameters=BehaveAgent._get_parameters(mock_context),
attributes=ba._attributes(mock_scenario),
test_case_id=ba._test_case_id(mock_scenario),
some_key="some_value",
Expand Down

0 comments on commit 727d2d6

Please sign in to comment.