def test_ScanOverrides_parse_scan_name_overrides_cli_passed_scan_name_success(get_endpoint_mock, parse_webinspect_mock, run_env_mock): # Given overrides = _setup_overrides(expected_scan_name="Expected_Scan_Name") # When scan_overrides_object = ScanOverrides(overrides) scan_overrides_object._parse_scan_name_overrides() # Expect assert scan_overrides_object.scan_name in ["Expected_Scan_Name"]
def test_ScanOverrides_parse_scan_name_overrides_success(get_endpoint_mock, parse_webinspect_mock, run_env_mock): # Given overrides = _setup_overrides() WebInspectLogHelper.log_error_scan_overrides_parsing_error = MagicMock() # When scan_overrides_object = ScanOverrides(overrides) scan_overrides_object._parse_scan_name_overrides() # Expect assert scan_overrides_object.scan_name[0:11] in ['webinspect-'] # the randomly generated scan name
def test_ScanOverrides_parse_scan_name_overrides_jenkins_job_BUILD_TAG_success( get_endpoint_mock, parse_webinspect_mock, run_env_mock, getenv_mock): # Given run_env_mock.return_value = "jenkins" # _parse_scan_name_overrides makes 2 calls to getevn, first one checks if there is a / in the return value and # follows 2 different paths. We want to test both paths getenv_mock.side_effect = ["/JOB_NAME/", "EXPECTED_BUILD_TAG"] overrides = _setup_overrides() # When scan_overrides_object = ScanOverrides(overrides) scan_overrides_object._parse_scan_name_overrides() # Expect assert scan_overrides_object.scan_name in ['EXPECTED_BUILD_TAG']