Skip to content

Commit c4951f8

Browse files
committed
First nested steps tests
1 parent 282f7b5 commit c4951f8

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

tests/steps/conftest.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2022 https://reportportal.io .
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# https://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License
13+
14+
from six.moves import mock
15+
16+
from pytest import fixture
17+
18+
from reportportal_client.client import RPClient
19+
from reportportal_client.steps import StepReporter
20+
21+
22+
@fixture
23+
def rp_client():
24+
client = RPClient('http://endpoint', 'project', 'token')
25+
client.session = mock.Mock()
26+
client.step_reporter = StepReporter(client)
27+
return client

tests/steps/test_steps.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) 2022 https://reportportal.io .
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# https://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License
13+
from reportportal_client import step
14+
15+
NESTED_STEP_NAME = 'test nested step'
16+
PARENT_STEP_ID = '123-123-1234-123'
17+
NESTED_STEP_ID = '321-321-4321-321'
18+
19+
20+
def test_nested_steps_are_skipped_without_parent(rp_client):
21+
with step(NESTED_STEP_NAME, rp_client=rp_client):
22+
print("Hello nested steps")
23+
assert rp_client.session.post.call_count == 0
24+
assert rp_client.session.put.call_count == 0
25+
26+
27+
def test_nested_steps_reported_with_parent(rp_client):
28+
rp_client.step_reporter.set_parent('STEP', PARENT_STEP_ID)
29+
30+
with step(NESTED_STEP_NAME, rp_client=rp_client):
31+
print("Hello nested steps")
32+
assert rp_client.session.post.call_count == 1
33+
assert rp_client.session.put.call_count == 1

0 commit comments

Comments
 (0)