tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_1610026_mobilesuica.py (1531B)


      1 import pytest
      2 
      3 ADDRESS_CSS = "input[name=MailAddress]"
      4 PASSWORD_CSS = "input[name=Password]"
      5 CLOSE_BUTTON_CSS = "input[name=winclosebutton]"
      6 UNAVAILABLE_TEXT = "時間をお確かめの上、再度実行してください。"
      7 UNSUPPORTED_TEXT = "ご利用のブラウザでは正しく"
      8 
      9 
     10 async def verify_site_loads(client):
     11    await client.navigate("https://www.mobilesuica.com/")
     12 
     13    error1, error2, site_is_down, address = client.await_first_element_of(
     14        [
     15            client.css(CLOSE_BUTTON_CSS),
     16            client.text(UNSUPPORTED_TEXT),
     17            client.text(UNAVAILABLE_TEXT),
     18            client.css(ADDRESS_CSS),
     19        ],
     20        is_displayed=True,
     21        timeout=10,
     22    )
     23 
     24    # The page can be down at certain times, making testing impossible. For instance:
     25    # "モバイルSuicaサービスが可能な時間は4:00~翌日2:00です。
     26    #  時間をお確かめの上、再度実行してください。"
     27    # "Mobile Suica service is available from 4:00 to 2:00 the next day.
     28    #  Please check the time and try again."
     29    if site_is_down:
     30        pytest.xfail("Site is currently down")
     31        return False
     32 
     33    if error1 or error2:
     34        return False
     35 
     36    return address and client.await_css(PASSWORD_CSS, is_displayed=True)
     37 
     38 
     39 @pytest.mark.asyncio
     40 @pytest.mark.with_interventions
     41 async def test_enabled(client):
     42    await verify_site_loads(client)
     43 
     44 
     45 @pytest.mark.asyncio
     46 @pytest.mark.without_interventions
     47 async def test_disabled(client):
     48    assert not await verify_site_loads(client)