def test_get_image_discrepancy_coordinates_exceptions(copy_test_files_to_board, test_data): x1, y1, x2, y2, error = test_data path_1, path_2 = get_path_for_images() with pytest.raises(error): # set incorrect coordinates values get_images_discrepancy(path_1, path_1, ScreenPoint(x1, y1), ScreenPoint(x2, y2))
def test_comparison_same_part_screenshots(copy_test_files_to_board): path_1, path_2 = get_path_for_images() # add equal images to compare discrepancy_percentage = get_images_discrepancy(path_1, path_1, ScreenPoint(10, 10), ScreenPoint(50, 50)) assert discrepancy_percentage == 0
def test_comparison_different_whole_screenshots_if_zero_coordinates( copy_test_files_to_board): path_1, path_2 = get_path_for_images() # add equal images to compare discrepancy_percentage = get_images_discrepancy(path_1, path_2, ScreenPoint(0, 0), ScreenPoint(0, 0)) assert 0 < discrepancy_percentage <= 100
def test_comparison_pictures(copy_test_files_to_board, test_data): image1, image2, left_point, right_point, expected_percentage = test_data images_list = copy_test_files_to_board # file validation if image1 not in images_list or image2 not in images_list: raise ValueError( 'Test images do not contain provided test files: [{} | {}]\n Possible list is {}' .format(image1, image2, images_list)) path_1, path_2 = get_path_for_images(image1, image2) discrepancy_percentage = get_images_discrepancy(path_1, path_2, left_point, right_point) assert discrepancy_percentage == expected_percentage
def test_comparison_different_part_screenshots(copy_test_files_to_board): path_1, path_2 = get_path_for_images() discrepancy_percentage = get_images_discrepancy(path_1, path_2, ScreenPoint(10, 10), ScreenPoint(50, 50)) assert 0 < discrepancy_percentage <= 100
def test_comparison_same_whole_screenshots(copy_test_files_to_board): path_1, path_2 = get_path_for_images() # add equal images to compare discrepancy_percentage = get_images_discrepancy(path_1, path_1) assert discrepancy_percentage == 0
def test_comparison_different_whole_screenshots(copy_test_files_to_board): path_1, path_2 = get_path_for_images() discrepancy_percentage = get_images_discrepancy(path_1, path_2) assert 0 < discrepancy_percentage <= 100
def test_exception_empty_path_to_file(app_connector): with pytest.raises(EmptyScreenshotFileName): get_images_discrepancy('', '')
def test_unsupport_file(create_unsupport_file): path = create_unsupport_file with pytest.raises(UnsupportedFileType): get_images_discrepancy(path, path)
def test_exceptionfor_file_zero_size(create_zero_size_file): path = create_zero_size_file with pytest.raises(ComparingImageIncorrectSize): get_images_discrepancy(path, path)
def test_exception_not_exist_image(app_connector): incorrect_path = 'incorrect_folder/incorrect_file.png' with pytest.raises(ComparingImageNotExist): get_images_discrepancy(incorrect_path, incorrect_path)