Skip to content

Commit a6770a6

Browse files
fix exisitng test
1 parent 367298d commit a6770a6

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

l10n_CM/run_l10n.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"tiffany",
5050
"assos",
5151
"zooplus",
52-
"duka"
52+
"duka",
5353
}
5454

5555
loaded_valid_sites = valid_l10n_mappings().keys()

modules/page_object_fxa_home.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ def fill_password(self, password: str) -> BasePage:
1616
self.set_content_context()
1717
self.fill("login-password-input", password, press_enter=False)
1818
self.get_element("submit-button").click()
19-
self.element_visible("signed-in-status")
2019
return self
2120

21+
def is_otp_input_required(self) -> bool:
22+
return len(self.get_elements("otp-input")) > 0
23+
2224
def create_new_account(self, password: str, age=30) -> BasePage:
2325
"""Fill out the password and age fields, then submit and wait for code"""
2426
self.fill("signup-password-input", password, press_enter=False)

tests/sync_and_fxa/conftest.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99

1010
class FxaSession:
11-
def __init__(self, url: str, password: str, restmail_session=None):
11+
def __init__(self, url: str, password: str, restmail_session):
1212
self.client = Client(url)
13-
self.restmail = restmail_session if restmail_session else TestEmailAccount()
13+
self.restmail = restmail_session
1414
self.password = password
1515
self.otp_code = None
1616
logging.info(self.restmail.email)
@@ -54,20 +54,20 @@ def add_to_prefs_list():
5454
return []
5555

5656

57+
@pytest.fixture()
58+
def acct_password():
59+
return "Test123???"
60+
61+
5762
@pytest.fixture()
5863
def fxa_session(
59-
fxa_url: str, fxa_env: str, acct_password: str, fxa_test_account, request
60-
) -> FxaSession:
64+
fxa_url: str, fxa_env: str, acct_password: str, restmail_session, request
65+
):
6166
"""Create a PyFxA object and return a dict with artifacts"""
62-
# Create a testing account using an @restmail.net address.
67+
# Create a testing account using and @restmail.net address.
6368
if fxa_env == "stage":
6469
fxa_url = "https://api-accounts.stage.mozaws.net"
65-
if fxa_test_account:
66-
prep = FxaSession(
67-
fxa_url, acct_password, request.getfixturevalue("restmail_session")
68-
)
69-
else:
70-
prep = FxaSession(fxa_url, acct_password)
70+
prep = FxaSession(fxa_url, acct_password, restmail_session)
7171
prep.restmail.clear()
7272
yield prep
7373
prep.destroy_account()
@@ -76,7 +76,7 @@ def fxa_session(
7676
@pytest.fixture()
7777
def fxa_test_account():
7878
"""return none by default"""
79-
return None
79+
return None, None
8080

8181

8282
@pytest.fixture()
@@ -86,10 +86,11 @@ def restmail_session(fxa_test_account) -> TestEmailAccount:
8686

8787

8888
@pytest.fixture()
89-
def create_fxa(fxa_session: FxaSession, get_otp_code) -> FxaSession:
89+
def create_fxa(restmail_session, fxa_session: FxaSession, get_otp_code) -> FxaSession:
9090
"""Create FxA from a PyFxA object"""
9191
fxa_session.create_account()
92-
fxa_session.session.verify_email_code(get_otp_code())
92+
code = get_otp_code(restmail_session) if restmail_session else get_otp_code()
93+
fxa_session.session.verify_email_code(code)
9394
return fxa_session
9495

9596

tests/sync_and_fxa/test_existing_fxa.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def test_sync_existing_fxa(
2727
driver: Firefox,
2828
fxa_test_account: Tuple[str, str],
2929
restmail_session,
30+
get_otp_code,
3031
screenshot,
3132
):
3233
"""C131098: User is able to log in with existing FxAccount"""
@@ -36,5 +37,9 @@ def test_sync_existing_fxa(
3637
fxa = FxaHome(driver)
3738
fxa.sign_up_sign_in(email)
3839
fxa.fill_password(password)
40+
if fxa.is_otp_input_required():
41+
otp = get_otp_code(restmail_session)
42+
fxa.fill_otp_code(otp)
43+
fxa.element_visible("signed-in-status")
3944
status_element = fxa.get_element("signed-in-status").find_element(By.TAG_NAME, "p")
4045
assert "You’re signed in" in status_element.text

tests/sync_and_fxa/test_new_fxa.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ def fxa_env():
1616
return "stage"
1717

1818

19-
@pytest.fixture()
20-
def acct_password():
21-
return "Test123???"
22-
23-
2419
def test_sync_new_fxa(driver: Firefox, fxa_url: str, fxa_session: dict, get_otp_code):
2520
"""C131094: The user is able to create a new Firefox Account"""
2621

0 commit comments

Comments
 (0)