diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 0000000..10c3420 --- /dev/null +++ b/tests/integration/__init__.py @@ -0,0 +1 @@ +"""Module: Integration Tests.""" diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index efad9e5..b52c88d 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -3,16 +3,103 @@ Conftest for use with integration tests for Grasshopper. """ +import logging import os +import random -# import pytest +import gevent +import pytest +from requests import Request +from requests_mock import ANY + +pytest_plugins = ["pytester"] GRASSHOPPER_CONFIG_FILE_PATH = os.path.join( os.path.abspath(os.path.dirname(__file__)), "grasshopper.config" ) -# Leaving this here because sometimes we want to turn it on for testing, but we don't -# want to use a config file unless the grasshopper consumer supplies one -# @pytest.fixture(scope="session") -# def grasshopper_config_file_path(): -# return GRASSHOPPER_CONFIG_FILE_PATH + +@pytest.fixture +def std_gh_output_msgs(): + msgs = [ + construct_msg("-+ Grasshopper configuration -+"), + construct_msg("-+ THRESHOLD REPORT -+"), + construct_msg("-+ CHECKS REPORT -+"), + construct_msg("-+ /Grasshopper configuration -+"), + ] + + return msgs + + +@pytest.fixture +def std_gh_out_with_cfg_msgs(std_gh_output_msgs): + std_gh_output_msgs.append(construct_msg(r"shape: \[Default\]")) + std_gh_output_msgs.append(construct_msg(r"users: \[\d+\]")) + std_gh_output_msgs.append(construct_msg(r"runtime: \[\d+(\.\d+)?\]")) + std_gh_output_msgs.append(construct_msg(r"spawn_rate: \[\d+\.\d+\]")) + std_gh_output_msgs.append(construct_msg(r"scenario_delay: \[\d+\.\d+\]")) + std_gh_output_msgs.append( + construct_msg( + r"shape_instance: \[\]" + ) + ) + std_gh_output_msgs.append( + construct_msg(r"user_classes: \[{: 1}\]") + ) + return std_gh_output_msgs + + +@pytest.fixture +def gh_out_add_trends_and_checks(std_gh_out_with_cfg_msgs): + trend_base = r"\s+\d\d\s+(\d+)ms\s+(\d+)ms" + check_base = r"\s+\d+\s+\d+\s+\d+\s+\d+(\.\d+)?" + + std_gh_out_with_cfg_msgs.append(construct_msg("PX_TREND_google_home" + trend_base)) + std_gh_out_with_cfg_msgs.append(construct_msg("google_home" + trend_base)) + std_gh_out_with_cfg_msgs.append(construct_msg("Status code is good" + check_base)) + + return std_gh_out_with_cfg_msgs + + +@pytest.fixture +def expected_output_messages(gh_out_add_trends_and_checks): + gh_out_add_trends_and_checks.append( + construct_msg("Check failed: Status code is good", target_level=logging.WARNING) + ) + return gh_out_add_trends_and_checks + + +@pytest.fixture +def expected_output_messages_add_yaml_specific_cfg(expected_output_messages): + expected_output_messages.append( + construct_msg(r"scenario_test_file_name: \[test__journey1.py\]") + ) + expected_output_messages.append( + construct_msg(r"scenario_tags: \[\['smoke', 'trend'\]\]") + ) + expected_output_messages.append( + construct_msg(r"scenario_file: \[.*scenario(s)?.yaml\]") + ) + expected_output_messages.append(construct_msg(r"scenario_name: \[scenario\d+\]")) + return expected_output_messages + + +def construct_msg(msg_re, target_level=logging.INFO): + """Construct a message dictionary, for use with validation.""" + msg = { + "target_level": target_level, + "target_message_re": msg_re, + } + return msg + + +@pytest.fixture +def mock_requests_get_mix_status_codes(requests_mock): + def response_provider_mix_of_status_codes(request: Request, context): + context.status_code = random.choice([200, 200, 200, 201, 403, 500]) + sleep_time = random.randint(1, 3) / 10 + gevent.sleep(sleep_time) + return {"data": f"mocked response {context.status_code}"} + + requests_mock.get(ANY, json=response_provider_mix_of_status_codes) + return requests_mock diff --git a/tests/integration/test__configuration_integration_with_pytest.py b/tests/integration/test__configuration_integration_with_pytest.py deleted file mode 100644 index 83f6df8..0000000 --- a/tests/integration/test__configuration_integration_with_pytest.py +++ /dev/null @@ -1,27 +0,0 @@ -from unittest.mock import MagicMock - -import pytest - - -@pytest.fixture -def environment(): - return MagicMock() - - -def test_all_the_args( - environment, - global_defaults, - grasshopper_config_file_args, - cmdln_args, - env_var_args, - complete_configuration, - pre_processed_args, - scenario_file_args, -): - print(f"GLOBAL DEFAULTS: {global_defaults}") - print(f"GLOBAL CONFIG FILE: {grasshopper_config_file_args}") - print(f"CMDLINE ARGS: {cmdln_args}") - print(f"ENV VAR ARGS: {env_var_args}") - print(f"PRE-PROCESSED ARGS: {pre_processed_args}") - print(f"SCENARIO_FILE_ARGS: {scenario_file_args}") - print(f"COMPLETE NEW: {complete_configuration}") diff --git a/tests/integration/test__configuration_loading.py b/tests/integration/test__configuration_loading.py new file mode 100644 index 0000000..78ed956 --- /dev/null +++ b/tests/integration/test__configuration_loading.py @@ -0,0 +1,26 @@ +import logging + +from assertpy import assert_that + +from grasshopper.lib.configuration.gh_configuration import GHConfiguration + +logger = logging.getLogger(__name__) + + +def test__complete_configuration__simplest_case(complete_configuration): + """Validate the whole 'stack' of fixtures that produce complete_configuration. + + This test validates that all the fixtures feed into complete_configuration without + errors and that the result of the entire process is a GHConfiguration object with + about the right amount (currently there are 12, but this may change if more + defaults are added). + + Note that in this case, most of the fixtures are not contributing additional + values. + + """ + logger.debug(f"COMPLETE CONFIGURATION: {complete_configuration}") + + assert_that(complete_configuration).is_instance_of(GHConfiguration) + # without supplying much, complete configuration should be >=12 items + assert_that(len(complete_configuration)).is_greater_than(11) diff --git a/tests/integration/test__grasshopper_runs.py b/tests/integration/test__grasshopper_runs.py new file mode 100644 index 0000000..fb7cdd6 --- /dev/null +++ b/tests/integration/test__grasshopper_runs.py @@ -0,0 +1,207 @@ +import logging + +from assertpy import assert_that + +from tests.integration.conftest import construct_msg # noqa: I202 +from tests.unit.conftest import ( # noqa: I202 + calculate_path, + perform_pytester_test_with_optional_log_capture, + was_message_logged, +) + +logger = logging.getLogger(__name__) + +MIN_NUMBER_OF_REQUESTS = 10 + + +def validate_number_of_iterations( + caplog, mock_requests, min_iterations=MIN_NUMBER_OF_REQUESTS +): + # assert that the requests_mock was called a reasonable number of times + assert_that(mock_requests.call_count).is_greater_than(min_iterations) + + # check that a reasonable number of messages coming from the @task are in caplog + _, starting_msgs = was_message_logged( + caplog=caplog, + target_message_re=r"VU \d+: Starting journey1_task", + target_level=logging.INFO, + ) + assert_that( + len(starting_msgs), f"Actual contents of msg list {starting_msgs}" + ).is_greater_than(min_iterations) + _, return_msgs = was_message_logged( + caplog=caplog, + target_message_re=r"VU \d+: Google result: [200|403|500]", + target_level=logging.INFO, + ) + assert_that( + len(return_msgs), f"Actual contents of msg list {return_msgs}" + ).is_greater_than(min_iterations) + + +def test__grasshopper__py__running_with_config_defaults( + pytester, + caplog, + expected_output_messages, + mock_requests_get_mix_status_codes, +): + """Short, but complete, grasshopper run. + + Run directly against a journey py file, using mainly the configuration defaults. + The non default items added are thresholds (found in the defaults on the class) + and the runtime has been overridden to be shorter (so that the test isn't too long). + + """ + dummy_journey_file = calculate_path( + "test__journey1.py", subdir="../integration_testing_data" + ) + + pytester.copy_example(dummy_journey_file) + perform_pytester_test_with_optional_log_capture( + pytester, + target="test__journey1.py", + args=["--runtime=20"], # override time so test does not take _too_ long + caplog=caplog, + target_messages=expected_output_messages, + ) + validate_number_of_iterations(caplog, mock_requests_get_mix_status_codes) + + +def test__grasshopper__yaml__collect_entire_file( + pytester, + caplog, + expected_output_messages_add_yaml_specific_cfg, + mock_requests_get_mix_status_codes, +): + """Short, but complete, grasshopper run. + + Run directly against a scenario file, not providing a scenario name. + There is only one scenario in the scenario file being used. + + Per the grasshopper behavior, the scenario is providing some values that override + the defaults, but not much that actually changes behavior. Thresholds used are from + this file. + + Runtime is still being overridden so that the test does not take _too_ long. + + """ + expected_output_messages = expected_output_messages_add_yaml_specific_cfg + dummy_journey_file = calculate_path( + "test__journey1.py", subdir="../integration_testing_data" + ) + dummy_scenario_file = calculate_path( + "single_scenario.yaml", subdir="../integration_testing_data" + ) + + pytester.copy_example(dummy_journey_file) + pytester.copy_example(dummy_scenario_file) + perform_pytester_test_with_optional_log_capture( + pytester, + target="single_scenario.yaml", + args=["--runtime=20"], # override time so test does not take _too_ long + caplog=caplog, + target_messages=expected_output_messages, + ) + validate_number_of_iterations(caplog, mock_requests_get_mix_status_codes) + + +def test__grasshopper__yaml__collect_one_scenario( + pytester, + caplog, + expected_output_messages_add_yaml_specific_cfg, + mock_requests_get_mix_status_codes, +): + """Short, but complete, grasshopper run. + + Run directly against a scenario file, using tags to select the scenario. Only one + scenario should match in the file. + + Per the grasshopper behavior, the scenario is providing some values that override + the defaults, but not much that actually changes behavior. Thresholds used are from + this file. + + Runtime is still being overridden so that the test does not take _too_ long. + + """ + expected_output_messages = expected_output_messages_add_yaml_specific_cfg + dummy_journey_file = calculate_path( + "test__journey1.py", subdir="../integration_testing_data" + ) + dummy_scenario_file = calculate_path( + "multiple_scenarios.yaml", subdir="../integration_testing_data" + ) + + pytester.copy_example(dummy_journey_file) + pytester.copy_example(dummy_scenario_file) + + # this message appears when a scenario is collected + expected_output_messages.append( + construct_msg( + r"Scenarios collected that match the specific tag query `scenario1`: " + r"\['scenario1'\]" + ) + ) + + perform_pytester_test_with_optional_log_capture( + pytester, + target="multiple_scenarios.yaml", + args=["--runtime=20", "--tags=scenario1"], # override time, select scenario + caplog=caplog, + target_messages=expected_output_messages, + ) + validate_number_of_iterations( + caplog, + mock_requests_get_mix_status_codes, + ) + + +def test__grasshopper__yaml__collect_multiple( + pytester, + caplog, + expected_output_messages_add_yaml_specific_cfg, + mock_requests_get_mix_status_codes, +): + """Short, but complete, grasshopper run. + + Run directly against a scenario file, using tags to select the scenario. The tag + should select 2 scenarios, which are essentially the same. + + Per the grasshopper behavior, the scenario is providing some values that override + the defaults, but not much that actually changes behavior. Thresholds used are from + this file. + + Runtime is still being overridden so that the test does not take _too_ long. + + """ + expected_output_messages = expected_output_messages_add_yaml_specific_cfg + dummy_journey_file = calculate_path( + "test__journey1.py", subdir="../integration_testing_data" + ) + dummy_scenario_file = calculate_path( + "multiple_scenarios.yaml", subdir="../integration_testing_data" + ) + + pytester.copy_example(dummy_journey_file) + pytester.copy_example(dummy_scenario_file) + + # this message appears when a scenario is collected + expected_output_messages.append( + construct_msg( + r"Scenarios collected that match the specific tag query `trend`: " + r"\['scenario1', 'scenario2'\]" + ) + ) + + perform_pytester_test_with_optional_log_capture( + pytester, + target="multiple_scenarios.yaml", + args=["--runtime=20", "--tags=trend"], # override time, collect 2 scenarios + outcomes={"passed": 2}, + caplog=caplog, + target_messages=expected_output_messages, + ) + validate_number_of_iterations( + caplog, + mock_requests_get_mix_status_codes, + min_iterations=MIN_NUMBER_OF_REQUESTS * 2, + ) diff --git a/tests/integration_testing_data/multiple_scenarios.yaml b/tests/integration_testing_data/multiple_scenarios.yaml new file mode 100644 index 0000000..5790989 --- /dev/null +++ b/tests/integration_testing_data/multiple_scenarios.yaml @@ -0,0 +1,35 @@ +scenario1: + test_file_name: 'test__journey1.py' + grasshopper_args: + users: 1 + spawn_rate: 1 + runtime: 120 + grasshopper_scenario_args: + thresholds: + PX_TREND_google_home: + type: custom + limit: 100 + google_home: + type: get + limit: 300 + tags: + - 'smoke' + - 'trend' + +scenario2: + test_file_name: 'test__journey1.py' + grasshopper_args: + users: 1 + spawn_rate: 1 + runtime: 120 + grasshopper_scenario_args: + thresholds: + PX_TREND_google_home: + type: custom + limit: 1000 + google_home: + type: get + limit: 50 + tags: + - 'smoke' + - 'trend' \ No newline at end of file diff --git a/tests/integration/scenarios.yaml b/tests/integration_testing_data/single_scenario.yaml similarity index 51% rename from tests/integration/scenarios.yaml rename to tests/integration_testing_data/single_scenario.yaml index 22a1d21..94b547f 100644 --- a/tests/integration/scenarios.yaml +++ b/tests/integration_testing_data/single_scenario.yaml @@ -3,12 +3,15 @@ scenario1: grasshopper_args: users: 1 spawn_rate: 1 - runtime: 600 + runtime: 120 grasshopper_scenario_args: - flow_name : 'POC flow' - recipe_name: 'Untitled recipe' - engine: 'photon' - thresholds: '{"{CUSTOM}PX_TREND_google_home": 1000}' + thresholds: + PX_TREND_google_home: + type: custom + limit: 100 + google_home: + type: get + limit: 300 tags: - 'smoke' - 'trend' \ No newline at end of file diff --git a/tests/integration/test__journey1.py b/tests/integration_testing_data/test__journey1.py similarity index 63% rename from tests/integration/test__journey1.py rename to tests/integration_testing_data/test__journey1.py index 2d98322..ffc27e3 100644 --- a/tests/integration/test__journey1.py +++ b/tests/integration_testing_data/test__journey1.py @@ -3,20 +3,27 @@ from locust import between, task from grasshopper.lib.grasshopper import BaseJourney, Grasshopper -from grasshopper.lib.util.utils import custom_trend +from grasshopper.lib.util.utils import check, custom_trend logger = logging.getLogger(__name__) class Journey1(BaseJourney): - wait_time = between(min_wait=30, max_wait=40) - defaults = {} + wait_time = between(min_wait=1, max_wait=2) + defaults = { + "runtime": 20, + "thresholds": { + "PX_TREND_google_home": {"type": "custom", "limit": 1000}, + "google_home": {"type": "get", "limit": 200}, + }, + } @task @custom_trend("PX_TREND_google_home") def journey1_task(self): logger.info(f"VU {self.vu_number}: Starting journey1_task") response = self.client.get("https://google.com", name="google_home") + check("Status code is good", response.status_code < 400, self.environment) logger.info(f"VU {self.vu_number}: Google result: {response.status_code}") diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 852b5db..d163e11 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -4,6 +4,7 @@ from pathlib import Path import pytest +from assertpy import assert_that pytest_plugins = ["pytester"] @@ -153,8 +154,10 @@ def calculate_path(filename, subdir="../fixture_testing_data"): return path -def perform_fixture_test_with_optional_log_capture( +def perform_pytester_test_with_optional_log_capture( pytester, + target="", + args=[], outcomes={"passed": 1}, caplog=None, target_messages=[], @@ -167,7 +170,7 @@ def perform_fixture_test_with_optional_log_capture( pytester documentation for more details. caplog - Simply pass the value of the pytest supplied fixture called `caplog`, - which your test will need to put into its signature.bWill only do a log capture if + which your test will need to put into its signature. Will only do a log capture if caplog is not None. target_messages - list of messages you expect to see in the captured logging for @@ -180,9 +183,9 @@ def perform_fixture_test_with_optional_log_capture( if caplog: with caplog.at_level(logging.DEBUG): # run all tests with pytest - result = pytester.runpytest() + result = pytester.runpytest(target, *args) else: - result = pytester.runpytest() + result = pytester.runpytest(target) # Step 2: Validate the outcomes from the test within the test result.assert_outcomes(**outcomes) @@ -195,7 +198,7 @@ def perform_fixture_test_with_optional_log_capture( caplog, **target_message, ) - assert found + assert_that(found, f"Expecting {target_message}").is_true() # return the result from pytester.runpytest() so that a test # may perform additional validations not provided for here diff --git a/tests/unit/test__fixture__cmdln_args.py b/tests/unit/test__fixture__cmdln_args.py index 7a9676d..775919c 100644 --- a/tests/unit/test__fixture__cmdln_args.py +++ b/tests/unit/test__fixture__cmdln_args.py @@ -5,7 +5,7 @@ PYFILE_ASSERT_EMPTY_CONFIG, PYFILE_ASSERT_EXPECTED_CONFIG, PYFILE_TEMPLATE, - perform_fixture_test_with_optional_log_capture, + perform_pytester_test_with_optional_log_capture, ) from grasshopper.lib.configuration.gh_configuration import ( # noqa: N817 @@ -14,6 +14,7 @@ FIXTURE_UNDER_TEST = "cmdln_args" + # Some comments on testing fixture cmdln_args. # The source of values for this fixture is pytest's request.config object. We are going # on the assumption that this fixture is well tested by the pytest package and are only @@ -47,7 +48,7 @@ def request_config(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) def test__cmdln_args__empty_cmdln(pytester): @@ -75,7 +76,7 @@ def request_config(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) def test__cmdln_args__extra_args_coming_from_cmdln(pytester): @@ -104,7 +105,7 @@ def request_config(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(CC.COMPLETE_ATTRS, clear=True) @@ -131,7 +132,7 @@ def request_config(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(CC.COMPLETE_ATTRS, clear=True) @@ -158,4 +159,4 @@ def request_config(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) diff --git a/tests/unit/test__fixture__env_var_args.py b/tests/unit/test__fixture__env_var_args.py index 06d1c03..a7f3747 100644 --- a/tests/unit/test__fixture__env_var_args.py +++ b/tests/unit/test__fixture__env_var_args.py @@ -7,7 +7,7 @@ PYFILE_ASSERT_EMPTY_CONFIG, PYFILE_ASSERT_EXPECTED_CONFIG, PYFILE_TEMPLATE, - perform_fixture_test_with_optional_log_capture, + perform_pytester_test_with_optional_log_capture, ) from grasshopper.lib.configuration.gh_configuration import ( # noqa: N817 @@ -83,7 +83,7 @@ def test__env_var_args__happy(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_NON_MATCHING_VALUES, clear=True) @@ -103,7 +103,7 @@ def test__env_var_args__no_matches(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, clear=True) @@ -122,7 +122,7 @@ def test__env_var_args__environ_empty(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_KEYS_MATCHING_OTHER_SOURCES, clear=True) @@ -150,7 +150,7 @@ def extra_env_var_keys(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_KEYS_MATCHING_OTHER_SOURCES, clear=True) @@ -179,7 +179,7 @@ def env_var_prefix_key(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_KEYS_THAT_WONT_RESOLVE, clear=True) @@ -204,7 +204,7 @@ def env_var_prefix_key(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_ALL_SOURCES_AND_NON_MATCHING_VALUES, clear=True) @@ -240,7 +240,7 @@ def configuration_extra_env_var_keys(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_SOME_MATCHING_VALUES, clear=True) @@ -260,7 +260,7 @@ def test__env_var_args__empty_attrs(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, clear=True) @@ -280,4 +280,4 @@ def test__env_var_args__empty_attrs_and_empty_env_vars(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) diff --git a/tests/unit/test__fixture__env_var_extra_keys.py b/tests/unit/test__fixture__env_var_extra_keys.py index 06d1c03..a7f3747 100644 --- a/tests/unit/test__fixture__env_var_extra_keys.py +++ b/tests/unit/test__fixture__env_var_extra_keys.py @@ -7,7 +7,7 @@ PYFILE_ASSERT_EMPTY_CONFIG, PYFILE_ASSERT_EXPECTED_CONFIG, PYFILE_TEMPLATE, - perform_fixture_test_with_optional_log_capture, + perform_pytester_test_with_optional_log_capture, ) from grasshopper.lib.configuration.gh_configuration import ( # noqa: N817 @@ -83,7 +83,7 @@ def test__env_var_args__happy(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_NON_MATCHING_VALUES, clear=True) @@ -103,7 +103,7 @@ def test__env_var_args__no_matches(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, clear=True) @@ -122,7 +122,7 @@ def test__env_var_args__environ_empty(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_KEYS_MATCHING_OTHER_SOURCES, clear=True) @@ -150,7 +150,7 @@ def extra_env_var_keys(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_KEYS_MATCHING_OTHER_SOURCES, clear=True) @@ -179,7 +179,7 @@ def env_var_prefix_key(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_KEYS_THAT_WONT_RESOLVE, clear=True) @@ -204,7 +204,7 @@ def env_var_prefix_key(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_ALL_SOURCES_AND_NON_MATCHING_VALUES, clear=True) @@ -240,7 +240,7 @@ def configuration_extra_env_var_keys(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, FAKE_ENVIRON_SOME_MATCHING_VALUES, clear=True) @@ -260,7 +260,7 @@ def test__env_var_args__empty_attrs(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(os.environ, clear=True) @@ -280,4 +280,4 @@ def test__env_var_args__empty_attrs_and_empty_env_vars(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) diff --git a/tests/unit/test__fixture__env_var_prefix_key.py b/tests/unit/test__fixture__env_var_prefix_key.py index 5e08ad0..55c18bf 100644 --- a/tests/unit/test__fixture__env_var_prefix_key.py +++ b/tests/unit/test__fixture__env_var_prefix_key.py @@ -4,7 +4,7 @@ from tests.unit.conftest import ( # noqa: I202 CONFTEST_TEMPLATE, - perform_fixture_test_with_optional_log_capture, + perform_pytester_test_with_optional_log_capture, ) FIXTURE_UNDER_TEST = "env_var_prefix_key" @@ -35,7 +35,7 @@ def test_grasshopper_fixture(env_var_prefix_key): """ ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) def test__env_var_prefix_key__with_empty_prefix_str(pytester, caplog): @@ -63,7 +63,7 @@ def test_grasshopper_fixture(env_var_prefix_key): "target_message_re": "Fixture configuration_prefix_key may only be a non zero " "length str", } - perform_fixture_test_with_optional_log_capture( + perform_pytester_test_with_optional_log_capture( pytester, caplog=caplog, target_messages=msg ) @@ -93,6 +93,6 @@ def test_grasshopper_fixture(env_var_prefix_key): "target_message_re": "Fixture configuration_prefix_key may only be a non zero " "length str", } - perform_fixture_test_with_optional_log_capture( + perform_pytester_test_with_optional_log_capture( pytester, caplog=caplog, target_messages=msg ) diff --git a/tests/unit/test__fixture__extra_env_var_keys.py b/tests/unit/test__fixture__extra_env_var_keys.py index 1059b01..9b898e6 100644 --- a/tests/unit/test__fixture__extra_env_var_keys.py +++ b/tests/unit/test__fixture__extra_env_var_keys.py @@ -5,7 +5,7 @@ from tests.unit.conftest import ( # noqa: I202 CONFTEST_TEMPLATE, message_was_not_logged, - perform_fixture_test_with_optional_log_capture, + perform_pytester_test_with_optional_log_capture, ) FIXTURE_UNDER_TEST = "extra_env_var_keys" @@ -37,7 +37,7 @@ def test_grasshopper_fixture(extra_env_var_keys): assert_that(extra_env_var_keys).is_equal_to(['ENV1', 'ENV2']) """ ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) def test__extra_env_var_keys__none(pytester, caplog): @@ -67,7 +67,7 @@ def test_grasshopper_fixture(extra_env_var_keys): "target_message_re": "Fixture configuration_extra_env_var_keys may only return " "a list of strings", } - perform_fixture_test_with_optional_log_capture( + perform_pytester_test_with_optional_log_capture( pytester, caplog=caplog, target_messages=msg ) @@ -93,7 +93,7 @@ def test_grasshopper_fixture(extra_env_var_keys): assert_that(extra_env_var_keys).is_equal_to([]) """ ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) target_message_re = ( "Fixture configuration_extra_env_var_keys may only return a list of strings" ) @@ -130,7 +130,7 @@ def test_grasshopper_fixture(extra_env_var_keys): "target_message_re": "Fixture configuration_extra_env_var_keys may only return " "a list of strings", } - perform_fixture_test_with_optional_log_capture( + perform_pytester_test_with_optional_log_capture( pytester, caplog=caplog, target_messages=msg ) @@ -162,6 +162,6 @@ def test_grasshopper_fixture(extra_env_var_keys): "target_message_re": "Fixture configuration_extra_env_var_keys may only return " "a list of strings", } - perform_fixture_test_with_optional_log_capture( + perform_pytester_test_with_optional_log_capture( pytester, caplog=caplog, target_messages=msg ) diff --git a/tests/unit/test__fixture__global_defaults.py b/tests/unit/test__fixture__global_defaults.py index c89d211..ab00715 100644 --- a/tests/unit/test__fixture__global_defaults.py +++ b/tests/unit/test__fixture__global_defaults.py @@ -9,7 +9,7 @@ PYFILE_ASSERT_EMPTY_CONFIG, PYFILE_ASSERT_EXPECTED_CONFIG, PYFILE_TEMPLATE, - perform_fixture_test_with_optional_log_capture, + perform_pytester_test_with_optional_log_capture, ) from grasshopper.lib.configuration.gh_configuration import ( # noqa: N817 @@ -90,7 +90,7 @@ def test__global_defaults__finds_defaults_in_arbitrary_attrs(pytester): ), ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(CC.COMPLETE_ATTRS, ATTRS_WITH_NO_DEFAULTS, clear=True) @@ -110,7 +110,7 @@ def test__global_defaults__no_defaults_in_attrs(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) @patch.dict(CC.COMPLETE_ATTRS, clear=True) @@ -129,4 +129,4 @@ def test__global_defaults__empty_attrs(pytester): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) diff --git a/tests/unit/test__fixture__grasshopper_config_file_args.py b/tests/unit/test__fixture__grasshopper_config_file_args.py index 4a0b88d..8f4bd31 100644 --- a/tests/unit/test__fixture__grasshopper_config_file_args.py +++ b/tests/unit/test__fixture__grasshopper_config_file_args.py @@ -6,7 +6,7 @@ PYFILE_ASSERT_EXPECTED_CONFIG, PYFILE_TEMPLATE, calculate_path, - perform_fixture_test_with_optional_log_capture, + perform_pytester_test_with_optional_log_capture, ) FIXTURE_UNDER_TEST = "grasshopper_config_file_args" @@ -42,7 +42,7 @@ def grasshopper_config_file_path(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) def test__grasshopper_config_file_args__file_not_found(pytester, caplog): @@ -70,7 +70,7 @@ def grasshopper_config_file_path(): "target_message_re": "Skipping loading from grasshopper configuration file " "because (.+) not found", } - perform_fixture_test_with_optional_log_capture( + perform_pytester_test_with_optional_log_capture( pytester, caplog=caplog, target_messages=msg ) @@ -102,7 +102,7 @@ def grasshopper_config_file_path(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) def test__grasshopper_config_file_args__extra_section(pytester): @@ -132,7 +132,7 @@ def grasshopper_config_file_path(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) def test__grasshopper_config_file_args__invalid_yaml(pytester, caplog): @@ -159,7 +159,7 @@ def grasshopper_config_file_path(): "target_level": logging.WARNING, "target_message_re": "Unable to parse yaml file", } - perform_fixture_test_with_optional_log_capture( + perform_pytester_test_with_optional_log_capture( pytester, caplog=caplog, target_messages=msg ) @@ -188,6 +188,6 @@ def grasshopper_config_file_path(): "target_level": logging.WARNING, "target_message_re": "Unable to parse yaml file", } - perform_fixture_test_with_optional_log_capture( + perform_pytester_test_with_optional_log_capture( pytester, caplog=caplog, target_messages=msg ) diff --git a/tests/unit/test__fixture__pre_processed_args.py b/tests/unit/test__fixture__pre_processed_args.py index 345571a..be3ae14 100644 --- a/tests/unit/test__fixture__pre_processed_args.py +++ b/tests/unit/test__fixture__pre_processed_args.py @@ -3,7 +3,7 @@ PYFILE_ASSERT_EMPTY_CONFIG, PYFILE_ASSERT_EXPECTED_CONFIG, PYFILE_TEMPLATE, - perform_fixture_test_with_optional_log_capture, + perform_pytester_test_with_optional_log_capture, ) from grasshopper.lib.configuration.gh_configuration import GHConfiguration @@ -57,7 +57,7 @@ def cmdln_args(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) def test__pre_processed_args__empty_sources(pytester): @@ -97,7 +97,7 @@ def cmdln_args(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester) def test__pre_processed_args__with_precedence_applied(pytester): @@ -156,4 +156,4 @@ def cmdln_args(): ) ) - perform_fixture_test_with_optional_log_capture(pytester) + perform_pytester_test_with_optional_log_capture(pytester)