def test_image_match_settings_serialization(use_dom, enable_patterns,
                                            ignore_displacements, match_level,
                                            eyes, screenshot):
    settings = (Target.window().fully().use_dom(use_dom).enable_patterns(
        enable_patterns).ignore_displacements(
            ignore_displacements).match_level(match_level))
    exact_match_settings = ExactMatchSettings()
    exact_match_settings.match_threshold = 0.5
    eyes.configure.default_match_settings = ImageMatchSettings(
        match_level=MatchLevel.EXACT,
        exact=exact_match_settings,
        use_dom=use_dom)
    image_match_settings = MatchWindowTask.create_image_match_settings(
        settings, eyes)
    assert image_match_settings.match_level == match_level
    assert image_match_settings.use_dom == use_dom
    assert image_match_settings.enable_patterns == enable_patterns
    assert image_match_settings.ignore_displacements == ignore_displacements
    assert (image_match_settings.exact.match_threshold ==
            exact_match_settings.match_threshold)

    serialized_img = json.loads(json_utils.to_json(image_match_settings))
    assert serialized_img["matchLevel"] == match_level.value
    assert serialized_img["useDom"] == use_dom
    assert serialized_img["enablePatterns"] == enable_patterns
    assert serialized_img["ignoreDisplacements"] == ignore_displacements
    assert (serialized_img["exact"]["minDiffIntensity"] ==
            exact_match_settings.min_diff_intensity)
    assert (serialized_img["exact"]["minDiffWidth"] ==
            exact_match_settings.min_diff_width)
    assert (serialized_img["exact"]["minDiffHeight"] ==
            exact_match_settings.min_diff_height)
    assert (serialized_img["exact"]["matchThreshold"] ==
            exact_match_settings.match_threshold)
Example #2
0
    def _match_window(self, region_provider, tag, ignore_mismatch,
                      check_settings):
        # type: (RegionProvider, Text, bool, SeleniumCheckSettings) -> MatchResult
        # Update retry timeout if it wasn't specified.
        retry_timeout_ms = -1  # type: int
        if check_settings:
            retry_timeout_ms = check_settings.values.timeout

        check_settings = self._process_check_settings_values(check_settings)

        region = region_provider.get_region()
        logger.debug("params: ([{}], {}, {} ms)".format(
            region, tag, retry_timeout_ms))

        app_output = self._get_app_output_with_screenshot(
            None, None, check_settings)
        result = self._match_window_task.perform_match(
            app_output=app_output,
            name=tag,
            ignore_mismatch=ignore_mismatch,
            image_match_settings=ImageMatchSettings.create_from_check_settings(
                check_settings),
            eyes=self,
            user_inputs=self._user_inputs,
            check_settings=check_settings,
            render_id=self.render_status.render_id,
            region_selectors=self._region_selectors,
            regions=self._regions,
        )
        return result
Example #3
0
def session_start_info():
    return SessionStartInfo(
        agent_id="eyes.core.python/3.15.4",
        session_type=SessionType.SEQUENTIAL,
        app_id_or_name="TestApp",
        ver_id=None,
        scenario_id_or_name="TestName",
        batch_info=BatchInfo(),
        baseline_env_name="Baseline env name",
        environment_name="Env name",
        environment=AppEnvironment(),
        default_match_settings=ImageMatchSettings(
            match_level=MatchLevel.STRICT),
        branch_name="branch Name",
        parent_branch_name="parentBranchName",
        baseline_branch_name="baselineBranchName",
        save_diffs=True,
        render=False,
        properties=[],
    )
def test_multithreading_serialization(i):
    mwd = MatchWindowData(
        agent_setup=None,
        app_output=AppOutput(
            dom_url="https://eyespublicwusi0.core/bl9crP4n81pwT9anq3r1Xr8g0e97eMliN8f7etrM110",
            screenshot_url="https://eyespublicwusi0.blob.core/g0e97eMliN8f7etrM110",
            viewport=RectangleSize(height=1300, width=2560),
            title="",
            screenshot_bytes=None,
        ),
        ignore_mismatch=False,
        user_inputs=[],
        tag="Capture",
        render_id="bf3ce18291b4aa933bee",
        options=Options(
            force_match=False,
            force_mismatch=False,
            ignore_mismatch=False,
            ignore_match=False,
            image_match_settings=ImageMatchSettings(
                ignore_regions=[
                    Region(height=41, left=30, top=165, width=738),
                    Region(height=32, left=30, top=480, width=738),
                ]
            ),
            name="Capture",
            render_id="bf3ce18291b4aa933bee",
            replace_last=False,
            source="applitoolscasppe.cm",
            user_inputs=[],
        ),
    )
    with ThreadPoolExecutor() as executor:
        results = list(executor.map(json_utils.to_json, [mwd] * 100))

    assert len(results) == 100

    for i, r in enumerate(results):
        assert "Ignore" in r
        assert "ignoreRegions" not in r
Example #5
0
    "verId": null,
    "branchName": null,
    "parentBranchName": null,
    "properties": []
}"""
SESSION_START_INFO_OBJ = SessionStartInfo(
    agent_id="eyes.core.python/3.15.4",
    session_type=SessionType.SEQUENTIAL,
    app_id_or_name="TestApp",
    ver_id=None,
    scenario_id_or_name="TestName",
    batch_info=BatchInfo(),
    baseline_env_name="Baseline env name",
    environment_name="Env name",
    environment=AppEnvironment(),
    default_match_settings=ImageMatchSettings(match_level=MatchLevel.STRICT),
    branch_name="branch Name",
    parent_branch_name="parentBranchName",
    baseline_branch_name="baselineBranchName",
    save_diffs=True,
    render=False,
    properties=[],
)
RUNNING_SESSION_DATA_RESPONSE_ID = "some id"
RUNNING_SESSION_DATA_RESPONSE_URL = "http://some-session-url.com"
RUNNING_SESSION_DATA_RESPONSE_SESSION_ID = "some session id"
RUNNING_SESSION_DATA_RESPONSE_BATCH_ID = "other url"
RUNNING_SESSION_DATA_RESPONSE_BASELINE_ID = "other url"
RUNNING_SESSION_DATA_RESPONSE = """
{
    "id": "%s",
def image_match_settings():
    return ImageMatchSettings()