Commit a00be4c3 by Eric Fischer

Fix broken auto_auth page

parent 6db440fc
""" """
Auto-auth page (used to automatically log in during testing). Auto-auth page (used to automatically log in during testing).
""" """
import json
import os import os
import re import re
import urllib import urllib
...@@ -54,6 +54,8 @@ class AutoAuthPage(PageObject): ...@@ -54,6 +54,8 @@ class AutoAuthPage(PageObject):
if roles is not None: if roles is not None:
self._params['roles'] = roles self._params['roles'] = roles
self.data = {}
@property @property
def url(self): def url(self):
""" """
...@@ -68,24 +70,17 @@ class AutoAuthPage(PageObject): ...@@ -68,24 +70,17 @@ class AutoAuthPage(PageObject):
return url return url
def is_browser_on_page(self): def is_browser_on_page(self):
message = self.q(css='BODY').text[0] self.data = json.loads(self.q(css='BODY').text[0])
match = re.search(r'Logged in user ([^$]+) with password ([^$]+) and user_id ([^$]+)$', message) return self.data['created_status'] == "Logged in"
return True if match else False
def get_user_id(self): def get_user_id(self):
""" """
Finds and returns the user_id Finds and returns the user_id
""" """
message = self.q(css='BODY').text[0].strip() return self.data['user_id']
match = re.search(r' user_id ([^$]+)$', message)
return match.groups()[0] if match else None
def get_username_and_email(self): def get_username_and_email(self):
""" """
Finds and returns the username and email address of the current user. Finds and returns the username and email address of the current user.
""" """
message = self.q(css='BODY').text[0].strip() return self.data['username'], self.data['email']
match = re.search(r'Logged in user (\S+) \((.*)\).*', message)
if not match:
return None
return match.group(1), match.group(2)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment