示例#1
0
def check_image_match_settings(eyes, test_result, comparision):
    session_results = get_session_results(eyes.api_key, test_result)
    img = session_results["actualAppOutput"][0]["imageMatchSettings"]
    for param in comparision:
        actual = img[param["actual_name"]]
        expected = param["expected"]
        if attr.has(expected.__class__):
            actual = attr_from_json(json.dumps(actual), expected.__class__)
        elif isinstance(expected, list):
            expected_cls = expected[0].__class__
            actual = [
                attr_from_json(json.dumps(a), expected_cls) for a in actual
            ]
        assert actual == expected
def test_test_results_deserialization():
    tr = json_utils.attr_from_json(get_resource("unit/testResultsData.json"),
                                   TestResults)  # type: TestResults
    assert tr.status == TestResultsStatus.Passed
    assert (
        tr.app_urls.batch ==
        "https://eyes.applitools.com/app/test-results/111?accountIdPczBANNug~~"
    )
    assert tr.accessibility_status == SessionAccessibilityStatus(
        AccessibilityStatus.Failed,
        AccessibilityLevel.AA,
        AccessibilityGuidelinesVersion.WCAG_2_0,
    )
    assert tr.host_display_size == RectangleSize(800, 800)
    assert tr.default_match_settings.ignore_regions == [
        Region(300, 300, 300, 300)
    ]
    assert tr.default_match_settings.accessibility == [
        AccessibilityRegion(300, 300, 300, 300,
                            AccessibilityRegionType.BoldText)
    ]
    assert tr.steps_info[0].name == "Login Window"
    assert (
        tr.steps_info[0].app_urls.step ==
        "https://eyes.applitools.com/app/test-results/00000215/steps/1?accountId=~"
    )
示例#3
0
def test_stop_session(started_connector):
    #  type: (ServerConnector) -> None
    respo = started_connector.stop_session(
        RUNNING_SESSION_OBJ, is_aborted=False, save=False
    )
    assert respo == attr_from_json(STOP_SESSION_DATA, TestResults)
    # should be False after stop_session
    assert not started_connector.is_session_started
示例#4
0
def test_stop_session(started_connector):
    #  type: (ServerConnector) -> None
    with patch("requests.delete", side_effect=mocked_requests_delete):
        respo = started_connector.stop_session(RUNNING_SESSION_OBJ,
                                               is_aborted=False,
                                               save=False)
    assert respo == attr_from_json(STOP_SESSION_DATA, TestResults)
    # should be False after stop_session
    assert not started_connector.is_session_started
示例#5
0
def test_parse_render_info_no_error(render_json):
    ri = attr_from_json(render_json, RenderingInfo,)
    if ri.service_url:
        assert ri.service_url == "url"
    if ri.access_token:
        assert ri.access_token == "token"
    if ri.results_url:
        assert ri.results_url == "result"
    if ri.stitching_service_url:
        assert ri.stitching_service_url == "stitching"
示例#6
0
def running_session():
    RUNNING_SESSION_DATA = """{
        "id": "some id",
        "sessionId": "some session id",
        "url": "http://some-session-url.com",
        "batchId": "other url",
        "baselineId": "other url"
    }"""
    RUNNING_SESSION_OBJ = attr_from_json(RUNNING_SESSION_DATA, RunningSession)
    return RUNNING_SESSION_OBJ
def demarshal_test_results(results_dict_list, config):
    # type: (List[dict], Optional[Configuration]) -> List[TestResults]
    results = [
        attr_from_json(dumps(r), TestResults) for r in results_dict_list
    ]
    if config:
        for result in results:
            if result:  # in case of internal USDK failure, None result is observed
                result.set_connection_config(config.server_url, config.api_key,
                                             config.proxy)
    return results
def test_running_session_serialization_and_deserialization():
    rs = RunningSession(
        id="some-id",
        session_id="session-id",
        batch_id="batch-id",
        baseline_id="baseline_id",
        url="url",
        is_new_session=True,
    )
    rs_json = json_utils.to_json(rs)
    assert '"isNew": true' in rs_json
    assert rs == json_utils.attr_from_json(rs_json, RunningSession)
def _parse_script_result(script_result):
    # type: (Text) -> (Separators, List, List, List)
    missing_css, missing_frames, data = [], [], []
    lines = re.split(r"\r?\n", script_result)
    separators = json_utils.attr_from_json(lines[0], Separators)
    blocks = [missing_css, missing_frames, data]
    block_index = 0
    for line in lines[1:]:
        if separators.separator == line:
            block_index += 1
        else:
            blocks[block_index].append(line)
    logger.info("missing css count: {}".format(len(missing_css)))
    logger.info("missing frames count: {}".format(len(missing_frames)))
    return separators, missing_css, missing_frames, data
示例#10
0
LONG_REQUEST_RESPONSE_URL = urljoin(CUSTOM_EYES_SERVER, "/second")

RENDER_INFO_URL = "https://render-wus.applitools.com"
RENDER_INFO_AT = "Some Token"
RENDERING_INFO_DATA = """
{
    "ServiceUrl": "%s",
    "AccessToken": "%s",
    "ResultsUrl": "%s?accessKey=%s"
}""" % (
    RENDER_INFO_URL,
    RENDER_INFO_AT,
    RUNNING_SESSION_DATA_URL,
    API_KEY,
)
RENDERING_OBJ = attr_from_json(RENDERING_INFO_DATA, RenderingInfo)


@pytest.fixture
def custom_eyes_server():
    return CUSTOM_EYES_SERVER


class MockResponse(object):
    def __init__(self, url, json_data, status_code, headers=None):
        self.url = url
        self.json_data = json_data
        self.status_code = status_code
        if headers is None:
            headers = {}
        self.headers = headers
def demarshal_match_result(results_dict):
    # type: (dict) -> MatchResult
    return attr_from_json(dumps(results_dict), MatchResult)