Skip to content

Commit b817bf5

Browse files
authored
Handle clients-tests requires section (#48)
* Handle clients-tests requires section * Mention `requires` section in comment
1 parent aba9787 commit b817bf5

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

test_elasticsearch_serverless/test_async/test_server/test_rest_api_spec.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ async def run_do(self, action):
130130
headers.pop("Authorization")
131131

132132
method, args = list(action.items())[0]
133-
args["headers"] = headers
133+
134+
if headers:
135+
args["headers"] = headers
134136

135137
# locate api endpoint
136138
for m in method.split("."):

test_elasticsearch_serverless/test_server/test_rest_api_spec.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -565,23 +565,31 @@ def remove_implicit_resolver(cls, tag_to_remove):
565565
yaml.load_all(package_zip.read(yaml_file), Loader=NoDatesSafeLoader)
566566
)
567567

568-
# Each file may have a "test" named 'setup' or 'teardown',
569-
# these sets of steps should be run at the beginning and end
570-
# of every other test within the file so we do one pass to capture those.
571-
setup_steps = teardown_steps = None
568+
# Each file has a `requires` section with `serverless` and `stack`
569+
# boolean entries indicating whether the test should run with
570+
# serverless, stack or both. Additionally, each file may have a section
571+
# named 'setup' or 'teardown', these sets of steps should be run at the
572+
# beginning and end of every other test within the file so we do one
573+
# pass to capture those.
574+
requires = setup_steps = teardown_steps = None
572575
test_numbers_and_steps = []
573576
test_number = 0
574577

575578
for yaml_test in yaml_tests:
576579
test_name, test_step = yaml_test.popitem()
577-
if test_name == "setup":
580+
if test_name == "requires":
581+
requires = test_step
582+
elif test_name == "setup":
578583
setup_steps = test_step
579584
elif test_name == "teardown":
580585
teardown_steps = test_step
581586
else:
582587
test_numbers_and_steps.append((test_number, test_step))
583588
test_number += 1
584589

590+
if not requires["serverless"]:
591+
continue
592+
585593
# Now we combine setup, teardown, and test_steps into
586594
# a set of pytest.param() instances
587595
for test_number, test_step in test_numbers_and_steps:

0 commit comments

Comments
 (0)