def create_ticket_type(cls, name=None, description=None, cost=None, release=True, quantity=100):
# Fill dummy data if not provided
if name == None: name = str(randint(0, 100000))
if description == None: description = "This is the demo description for %s" % name
if cost == None: cost = str(randint(0, 200))
else: cost = "%.2f" % (cost / 100.0)
# Enact an administration login
cls.admin_login()
# Go to the ticket type add page
cls.browser.get(cls.route_path("admin_ticket_type_add"))
cls.browser.find_element(By.ID, "name").send_keys(name)
cls.browser.find_element(By.ID, "description").send_keys(description)
cls.browser.find_element(By.ID, "cost").send_keys(cost)
# Check the group boxes so that purchaase is allowed
cls.browser.find_element(By.ID, "raven-group").click()
cls.browser.find_element(By.ID, "admin-group").click()
cls.browser.find_element(By.ID, "alumni-group").click()
cls.browser.find_element(By.ID, "committee-group").click()
cls.browser.find_element(By.ID, "submit").click()
# Ensure it added
cls.browser.get(cls.route_path("admin_tickets"))
assert name in cls.browser.page_source
# If we have been told to release then do so
if release: cls.release_tickets(name, quantity=quantity)
# Logout of admin account
cls.logout()
# Return its details
return (name, description, cost, quantity)
评论列表
文章目录