88
99
1010class 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 ()
5863def 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 ()
7777def 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
0 commit comments