|
1 | 1 | import pytest |
| 2 | +from mock import patch |
2 | 3 |
|
3 | 4 | from applitools.common import MatchLevel, StitchMode |
4 | 5 | from applitools.core import NullScaleProvider |
5 | 6 | from applitools.selenium import Eyes |
6 | 7 | from applitools.selenium.visual_grid import VisualGridRunner |
7 | 8 |
|
8 | 9 |
|
| 10 | +def get_start_session_info_from_open(eyes, driver): |
| 11 | + eyes.api_key = "Some API KEY" |
| 12 | + eyes._is_viewport_size_set = True |
| 13 | + |
| 14 | + with patch( |
| 15 | + "applitools.core.server_connector.ServerConnector.start_session" |
| 16 | + ) as start_session: |
| 17 | + with patch( |
| 18 | + "applitools.core.eyes_base.EyesBase._EyesBase__ensure_viewport_size" |
| 19 | + ): |
| 20 | + eyes.open(driver, "TestApp", "TestName") |
| 21 | + session_start_info = start_session.call_args_list[0][0][0] |
| 22 | + return session_start_info |
| 23 | + |
| 24 | + |
9 | 25 | def pytest_generate_tests(metafunc): |
10 | 26 | if "eyes" in metafunc.fixturenames: |
11 | 27 | metafunc.parametrize("eyes", ["selenium", "visual_grid"], indirect=True) |
@@ -59,3 +75,33 @@ def test_config_overwriting(eyes): |
59 | 75 | eyes2.configuration.host_app = "Other Host2" |
60 | 76 | assert eyes.host_app != eyes2.host_app |
61 | 77 | assert eyes.configuration.host_app != eyes2.configuration.host_app |
| 78 | + |
| 79 | + |
| 80 | +def test_baseline_name(eyes, driver_mock): |
| 81 | + eyes.baseline_branch_name = "Baseline" |
| 82 | + assert eyes.baseline_branch_name == "Baseline" |
| 83 | + assert eyes.configuration.baseline_branch_name == "Baseline" |
| 84 | + |
| 85 | + if not eyes._visual_grid_eyes: |
| 86 | + session_info = get_start_session_info_from_open(eyes, driver_mock) |
| 87 | + assert session_info.baseline_branch_name == "Baseline" |
| 88 | + |
| 89 | + |
| 90 | +def test_branch_name(eyes, driver_mock): |
| 91 | + eyes.branch_name = "Branch" |
| 92 | + assert eyes.branch_name == "Branch" |
| 93 | + assert eyes.configuration.branch_name == "Branch" |
| 94 | + |
| 95 | + if not eyes._visual_grid_eyes: |
| 96 | + session_info = get_start_session_info_from_open(eyes, driver_mock) |
| 97 | + assert session_info.branch_name == "Branch" |
| 98 | + |
| 99 | + |
| 100 | +def test_baseline_env_name(eyes, driver_mock): |
| 101 | + eyes.baseline_env_name = "Baseline Env" |
| 102 | + assert eyes.baseline_env_name == "Baseline Env" |
| 103 | + assert eyes.configuration.baseline_env_name == "Baseline Env" |
| 104 | + |
| 105 | + if not eyes._visual_grid_eyes: |
| 106 | + session_info = get_start_session_info_from_open(eyes, driver_mock) |
| 107 | + assert session_info.baseline_env_name == "Baseline Env" |
0 commit comments