示例#1
0
 def test_save_session_to_json(self, mock_open, mock_path, mock_load,
                               mock_dump):
     _set_mocks_for_json_file_exists(mock_path)
     test_session = Session()
     test_session.username = "******"
     test_session.server = "SRVR"
     test_session._save_session_to_json()
     assert mock_dump.was_called()
示例#2
0
 def test__create_new_username_credential_succeeds_new_password(
         self, mock_pass):
     test_password = "******"
     active_session = Session()
     active_session.username = "******"
     active_session.site = ""
     auth = active_session._create_new_credential(
         test_password, Session.PASSWORD_CRED_TYPE)
     assert auth is not None
示例#3
0
 def test__create_new_username_credential_succeeds_from_self(
         self, mock_pass):
     active_session = Session()
     active_session.username = "******"
     active_session.site = ""
     auth = active_session._create_new_credential(
         None, Session.PASSWORD_CRED_TYPE)
     assert mock_pass.has_been_called()
     assert auth is not None
     assert auth.username == "user3", auth
     assert auth.password == mock_pass(), auth
示例#4
0
 def test_save_then_read(self):
     test_session = Session()
     test_session.username = "******"
     test_session.server_url = fakeserver
     test_session.password_file = "users.csv"
     test_session._save_session_to_json()
     new_session = Session()
     new_session._read_from_json()
     assert new_session.username == "USN", new_session.username
     assert hasattr(new_session, "password") is False, new_session
     assert new_session.server_url == fakeserver, new_session.server_url
     test_session.end_session_and_clear_data()