示例#1
0
def test_wildcard_wait_for_object_with_searching_area_positive():
    wildcard_data = data(path, 'wildcard_test_data')
    wildcard = vhat_client.Wildcard(*wildcard_data)
    # to check several results
    check_wildcard_results_amount(wildcard.getMatchObjects(), wildcard_data, 2)

    try:
        obj = hmi.wait_for_object(wildcard)
        top_left, bottom_right = get_top_left_bottom_right_from_object(obj)
        hmi.wait_for_object(wildcard, DEF_TIMEOUT, top_left, bottom_right)
    except vhat_client.LookupError:
        assert False, 'Failed waitForObject for wildcard with params {}'.format(
            data(path, 'wildcard_test_data'))
示例#2
0
def test_neg_invalid_rectangle_coordinates_for_wildcard(test_data):
    top_left_coordinate, bottom_right_coordinate = test_data
    wildcard = vhat_client.Wildcard(*data(path, 'wildcard_test_data'))

    with pytest.raises(vhat_client.InvalidRectangleCoordinates) as exc:
        hmi.wait_for_object(wildcard, DEF_TIMEOUT, top_left_coordinate,
                            bottom_right_coordinate)
    logging.exception(exc)
示例#3
0
def test_wildcard_wait_for_object():
    wildcard_data = data(path, 'wildcard_test_data')
    wildcard = vhat_client.Wildcard(*wildcard_data)
    check_wildcard_results_amount(wildcard.getMatchObjects(), wildcard_data, 2)

    try:
        hmi.wait_for_object(wildcard)
    except vhat_client.LookupError:
        assert False, 'Failed waitForObject for wildcard with params {}'.format(
            wildcard_data)
示例#4
0
def test_wildcard_wait_for_object_with_searching_area_negative():
    wildcard_data = data(path, 'wildcard_test_data')
    wildcard = vhat_client.Wildcard(*wildcard_data)
    # to check several results
    check_wildcard_results_amount(wildcard.getMatchObjects(), wildcard_data, 2)

    with pytest.raises(vhat_client.LookupError) as exc:
        obj = hmi.wait_for_object(wildcard)
        top_left, bottom_right = get_negative_top_left_bottom_right_from_object(
            obj)
        hmi.wait_for_object(wildcard, DEF_TIMEOUT, top_left, bottom_right)
    logging.exception(exc)
示例#5
0
def jira_issue(jira_id=None,
               description=None,
               test_data=None,
               path=None,
               name=None):
    """
    decorator for issue specifying in allure report

    If the issue is not environment specific
    jira_id, description and test_data should be specified directly
    during the decoration.
    Example:
    @jira_issue('VHAT-123')
    @jira_issue('VHAT-123', 'sample description',['text1','text2'])

    Otherwise if the issue is environment specific,
    decorator should be called with path and name params specified
    for dynamically import the issue details
    Please note: there is no necessity to declare issue attribute
    in test_data module for all environments used (stubbed or etc)
     - create it only where it makes sense.
     Examples:
      test_data module attribute:
        vhat_123=('VHAT-123', 'sample description',['text1','text2'])
      usage in tests:
        @jira_issue(path='test_exists', name='vhat_123')

    :param jira_id: id of the defect ticket in JIRA
    :param description: text specified in allure report for the issue
    :param test_data: iterable of data reproduce the issue
    :param path: environment specific package name
     to look for test_data module
    :param name: name of the attribute in test_data module
     to look for details
    :return: allure.issue function call result
    """
    def wrapper(function):
        return function

    # getting data for environment specific issue
    if path and name:
        try:
            jira_id, description, test_data = data(path, name)
        # no issue mentioned in report if unable to find data for current environment
        except AttributeError:
            return wrapper
    # no issue mentioned in report if no jira_id specified
    if not jira_id:
        return wrapper
    description = _get_complete_description(description, jira_id, test_data)
    return allure.issue(_JIRA_TICKET_LINK.format(jira_id), description)
import allure
import pytest
from functional_tests.pages.hmi import get_objects_data_by_pattern
from functional_tests.tests.helpers import check_wildcard_results_content
from functional_tests.tests.import_helper_functions import data
from functional_tests.utils.sync3.constants import TASK_LINK
from vhat_client import Wildcard

pytestmark = [pytest.mark.regression_sync4, pytest.mark.regression_sync3, pytest.mark.getObjectsDataByPattern]

path = 'test_get_objects_data_by_pattern'


@allure.testcase(TASK_LINK.format("VHAT-1586"), "VHAT-1586")
@pytest.mark.parametrize('name', data(path, 'test_data_name'))
def test_get_objects_data_by_pattern_name(name):
    objects_list = get_objects_data_by_pattern(name)
    # TODO: update once question VHAT-1699 is answered
    assert len(objects_list) >= 1
    for item in objects_list:
        assert item.name == name


@allure.testcase(TASK_LINK.format("VHAT-1587"), "VHAT-1587")
@pytest.mark.parametrize('wildcard_pattern', data(path, 'test_data_wildcard'))
def test_get_objects_data_by_pattern_wildcard(wildcard_pattern):
    objects_list = get_objects_data_by_pattern(Wildcard(wildcard_pattern))
    check_wildcard_results_content(objects_list, wildcard_pattern)


@allure.issue(TASK_LINK.format("VHAT-1698"), "VHAT-1698")
示例#7
0
import pytest
import vhat_client
from functional_tests.pages.hmi import waitForObject
from functional_tests.pages.interaction import tap_if_visible
from functional_tests.tests.import_helper_functions import Data, data

path = 'test_tap_object'

to_page_object = data(path, name='to_page_object')
from_page_object = data(path, name='from_page_object')
check_object = data(path, name='check_object')


@pytest.fixture(scope='module')
def open_page(attach_to_app):
    """
    opens predefined page
    """
    Data(path).open_page()


@pytest.fixture()
def get_state_audio_button_object(open_page):
    """
    check activity test page: if activity -> return current page object(for ex. Audio Page)
    otherwise switch to other page(for ex. Phone Page) ->
    previous page is already activated (in this case Audio Page) ->
    return previous page object(i.e. Audio Page)
    :param fixture of opening page:
    :return: vhat_client.object
    """
示例#8
0
import pytest
from functional_tests.pages import hmi
from functional_tests.tests.import_helper_functions import Data, data
from functional_tests.utils.report import jira_issue, jira_test
from vhat_client import InvalidRectangleCoordinates

pytestmark = [pytest.mark.regression_sync4, pytest.mark.regression_sync3, pytest.mark.get_text]

path = "test_get_text"

check_object = data(path, name='check_object')
expected_text = data(path, name='expected_text')


@pytest.fixture(scope="function", name='open_test_page')
def open_page(attach_to_app):
    """
    opens predefined page
    """
    Data(path).open_method()


def get_coordinates_of_text_on_page():
    target = hmi.wait_for_object(check_object)
    # get left-up and right-down coordinates text +- 2pc as a recognition distance buffer
    recognition_distance_buffer = 2
    x1 = int(target.x - target.width / 2 - recognition_distance_buffer)
    y1 = int(target.y - target.height / 2 - recognition_distance_buffer)
    x2 = int(target.x + target.width / 2 + recognition_distance_buffer)
    y2 = int(target.y + target.height / 2 + recognition_distance_buffer)
    return [x1, y1, x2, y2]
示例#9
0
def test_wildcard_wait_for_object_no_text_detected():
    wildcard_data = {"name": data(path, 'text')}
    wildcard = vhat_client.Wildcard(wildcard_data)
    check_wildcard_results_amount(wildcard.getMatchObjects(), wildcard_data, 0)
    with pytest.raises(vhat_client.LookupError):
        hmi.wait_for_object(wildcard)
示例#10
0
def open_page(app_connector):
    open_function = data(path, name='open_page_method')
    open_function()
示例#11
0
from vhat_client import ScreenPoint

from functional_tests.pages import hmi
from functional_tests.tests.helpers import check_wildcard_results_amount
from functional_tests.tests.import_helper_functions import data
from functional_tests.utils.report import jira_test
from functional_tests.utils.sync4.constants import TASK_LINK

pytestmark = [
    pytest.mark.regression_sync4, pytest.mark.regression_sync3,
    pytest.mark.waitForObject
]

path = 'test_wait_for_object'

icon = data(path, name='icon')

DEF_LEFT_POINT = ScreenPoint(0, 0)
DEF_RIGHT_POINT = ScreenPoint(0, 0)
DEF_TIMEOUT = 1000

TEST_DATA_INVALID_RECTANGLE_COORDINATES = [
    (ScreenPoint(-10, 10), DEF_RIGHT_POINT),
    (DEF_LEFT_POINT, ScreenPoint(10, -10)),
    (ScreenPoint(9999, 9999), ScreenPoint(9999, 9999)),
    (ScreenPoint(9999, 10), ScreenPoint(10, 10)),
    (ScreenPoint(10, 9999), ScreenPoint(10, 10)),
    (ScreenPoint(10, 9999), ScreenPoint(9999, 10)),
    (ScreenPoint(10, 20), ScreenPoint(15, 20)),
    (ScreenPoint(10, 15), ScreenPoint(10, 20)),
    (ScreenPoint(15, 10), ScreenPoint(15, 10)),