-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Version
Version: 1.50.0
Steps to reproduce
- Write handle for page.route with failed assert:
def optimization_strategy(route: Route): assert 1=2 route.continue_() - Make routing:
campaigns_edit.page.route('*/**/campaigns/*', optimization_strategy)
And run
Expected behavior
Inside handler raised exception
Exception up to pytest
Test failed
Pytest make treport
Actual behavior
The exception did not occur in pytest.
The Endpoint response is blocked with the pending status.
The test crashed, so the next line with expect is executed, but the response to the monitored endpoint did not arrive.
Additional context
Full Code
`
import allure
import pytest
from playwright.sync_api import Route
from scr.helper.constants import UTM_MEDIUM_IS_CPC, TGB, TO_CHOOSE, CHOOSED, GB, ADS_SAVED
from scr.helper.general import tgb_valid_images_path
from scr.pages.campaigns_edit import CampaignsEdit
@allure.title('Значение utm_medium в зависимости от выбранной стратегии в кампании')
class TestUtmMediumValue:
@allure.title('Ссылка с cpm статегия предполагает cpc')
@pytest.mark.parametrize('link', [UTM_MEDIUM_IS_CPC])
@pytest.mark.parametrize('strategy', [('MAX_ENGAGED_SESSIONS_CPM'),
('MAX_IMPRESSION_MIN_COST'),
('MAX_IMPRESSION_AVG_COST'),
('MAX_CONVERSION'),
]
)
def test_create_ad_utm_medium_in_link_is_not_equal_utm_medium_in_campaign(self, test_name, link,
strategy,
campaigns_edit: CampaignsEdit):
def optimization_strategy(route: Route):
response = route.fetch()
json = response.json()
json['optimizationStrategy'] = strategy
route.fulfill(response=response, json=json)
campaigns_edit.page.route('*/**/campaigns/*', optimization_strategy)
campaigns_edit.move_to_create_ad()
def creatives_checker(route: Route):
if route.request.method != 'POST':
route.fallback()
return
response = route.fetch()
click_url = response.json()['assets'][0]['text'].contains('utm_medium=cpc')
assert 'utm_medium=cpc' in click_url
assert 'utm_medium=cpm' not in click_url
route.continue_()
def ads_checker(route: Route):
if route.request.method != 'POST':
route.fallback()
return
response = route.fetch()
json = response.json()
click_url = json['creative']['assets'][3]['url']
assert 'utm_medium=cpь' in click_url
assert 'utm_medium=cpm' not in click_url
route.continue_()
campaigns_edit.ads_name.clear()
campaigns_edit.fill_ads_name(test_name)
campaigns_edit.checker.check_ads_choose_button(TGB, CHOOSED)
campaigns_edit.checker.check_ads_choose_button(GB, TO_CHOOSE)
campaigns_edit.ads_selection_button.click(**{'ads_type': TGB})
campaigns_edit.ads_link.fill(link)
campaigns_edit.main_info_next_button.click()
campaigns_edit.checker.check_succes_main_link('https://cms-website-emulator.ift-mesh.ad-tech.ru/empty')
campaigns_edit.unwrap_utm_button.click()
campaigns_edit.checker.check_utm_item(['utm_medium=cpc '])
campaigns_edit.load_image_not_galery_and_check(tgb_valid_images_path, 'common_tgb.jpg',
check_is_preview_by_name=True)
campaigns_edit.ads_title.fill(test_name)
campaigns_edit.advertiser_name.fill(test_name)
campaigns_edit.choose_erir_category(name='Вино')
campaigns_edit.page.route('*/**/creatives/*', creatives_checker)
campaigns_edit.page.route('*/**/ads', ads_checker)
campaigns_edit.click_save_button()
campaigns_edit.checker.check_alert(
[ADS_SAVED]
)
`
Environment
- Operating System: [windows 10]
- CPU: [intel 10200H]
- Browser: [Chromium]
- Python Version: [3.10.11]