本文整理汇总了Python中s3.s3_debug函数的典型用法代码示例。如果您正苦于以下问题:Python s3_debug函数的具体用法?Python s3_debug怎么用?Python s3_debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s3_debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: helper_inv_track_send_item
def helper_inv_track_send_item(self, user, send_id, data, removed=True):
"""
Helper method to add a track item to the inv_send with the
given send_id by the given user
"""
try:
add_btn = self.browser.find_element_by_id("show-add-btn")
if add_btn.is_displayed():
add_btn.click()
except:
pass
self.login(account=user, nexturl="inv/send/%s/track_item" % send_id)
table = "inv_track_item"
result = self.create(table, data, dbcallback=self.dbcallback_getStockLevels)
# Get the last record in the before & after
# this will give the stock record which has been added to the end by
# the getStockLevels callback
if removed:
qnty = 0
for line in data:
if line[0] == "quantity":
qnty = float(line[1])
break
stock_before = result["before"].records[len(result["before"]) - 1].quantity
stock_after = result["after"].records[len(result["after"]) - 1].quantity
stock_shipped = qnty
self.assertTrue(
stock_before - stock_after == stock_shipped,
"Warehouse stock not properly adjusted, was %s should be %s but is recorded as %s"
% (stock_before, stock_after, stock_before - stock_shipped),
)
s3_debug("Stock level before %s, stock level after %s" % (stock_before, stock_after))
return result
示例2: dt_find
def dt_find(search = "",
row = None,
column = None,
tableID = "list",
first = False,
):
""" Find the cells where search is found in the dataTable """
# 'todo need to fix the searching on numbers
config = current.test_config
browser = config.browser
# Calculate the rows that need to be navigated along to find the search string
colList = []
rowList = []
if row == None:
r = 1
while True:
tr = ".//*[@id='%s']/tbody/tr[%s]" % (tableID, r)
try:
elem = browser.find_element_by_xpath(tr)
rowList.append(r)
r += 1
except:
break
elif isinstance(row, int):
rowList = [row]
else:
rowList = row
# Calculate the columns that need to be navigated down to find the search string
if column == None:
c = 1
while True:
td = ".//*[@id='%s']/tbody/tr[1]/td[%s]" % (tableID, c)
try:
elem = browser.find_element_by_xpath(td)
colList.append(c)
c += 1
except:
break
elif isinstance(column, int):
colList = [column]
else:
colList = column
s3_debug("rows %s, columns %s" % (rowList, colList))
# Now try and find a match
result = []
for r in rowList:
for c in colList:
td = ".//*[@id='%s']/tbody/tr[%s]/td[%s]" % (tableID, r, c)
try:
elem = browser.find_element_by_xpath(td)
s3_debug("got %s, needle %s" % (elem.text, search))
if elem.text == search:
if first:
return (r, c)
else:
result.append((r, c))
except:
pass
return result
示例3: logout
def logout():
""" Logout """
config = current.test_config
browser = config.browser
url = "%s/default/user/login" % config.url
browser.get(url)
try:
elem = browser.find_element_by_id("auth_menu_logout")
except NoSuchElementException:
s3_debug("Logged-out already")
return True
elem.click()
# Check the result
try:
elem = browser.find_element_by_xpath("//div[@class='confirmation']")
except NoSuchElementException:
assert 0, "Logout unsuccesful"
else:
s3_debug(elem.text)
return True
示例4: dt_links
def dt_links(row = 1,
tableID = "list",
quiet = True
):
""" Returns a list of links in the given row of the dataTable """
config = current.test_config
browser = config.browser
links = []
# loop through each column
column = 1
while True:
td = ".//*[@id='%s']/tbody/tr[%s]/td[%s]" % (tableID, row, column)
try:
elem = browser.find_element_by_xpath(td)
except:
break
# loop through looking for links in the cell
cnt = 1
while True:
link = ".//*[@id='%s']/tbody/tr[%s]/td[%s]/a[%s]" % (tableID, row, column, cnt)
try:
elem = browser.find_element_by_xpath(link)
except:
break
cnt += 1
if not quiet:
s3_debug("%2d) %s" % (column, elem.text))
links.append([column,elem.text])
column += 1
return links
示例5: dt_filter
def dt_filter(search_string=" ",
forceClear = True,
quiet = True):
""" filter the dataTable """
if forceClear:
if not dt_filter(forceClear = False,
quiet = quiet):
return False
config = current.test_config
browser = config.browser
sleep_limit = 10
elem = browser.find_element_by_css_selector('label > input[type="text"]')
elem.clear()
elem.send_keys(search_string)
time.sleep(1) # give time for the list_processing element to appear
waiting_elem = browser.find_element_by_id("list_processing")
sleep_time = 0
while (waiting_elem.value_of_css_property("visibility") == "visible"):
time.sleep(1)
sleep_time += 1
if sleep_time > sleep_limit:
if not quiet:
s3_debug("DataTable filter didn't respond within %d seconds" % sleep_limit)
return False
return True
示例6: dt_row_cnt
def dt_row_cnt(check = (),
quiet = True):
""" return the rows that are being displayed and the total rows in the dataTable """
config = current.test_config
browser = config.browser
elem = browser.find_element_by_id("list_info")
details = elem.text
if not quiet:
s3_debug(details)
words = details.split()
start = int(words[1])
end = int(words[3])
length = int(words[5])
filtered = None
if len(words) > 10:
filtered = int(words[9])
if check != ():
if len(check ) == 3:
expected = "Showing %d to %d of %d entries" % check
actual = "Showing %d to %d of %d entries" % (start, end, length)
assert (start, end, length) == check, "Expected result of '%s' doesn't equal '%s'" % (expected, actual)
elif len(check) == 4:
expected = "Showing %d to %d of %d entries (filtered from %d total entries)" % check
if filtered:
actual = "Showing %d to %d of %d entries (filtered from %d total entries)" % (start, end, length, filtered)
else:
actual = "Showing %d to %d of %d entries" % (start, end, length)
assert (start, end, length, filtered) == check, "Expected result of '%s' doesn't equal '%s'" % (expected, actual)
if len(words) > 10:
return (start, end, length, filtered)
else:
return (start, end, length)
示例7: hrm002
def hrm002():
config = current.test_config
browser = config.browser
driver = browser
driver.find_element_by_link_text("Staff & Volunteers").click()
driver.find_element_by_link_text("New Volunteer").click()
w_autocomplete("Rom","hrm_human_resource_organisation","Romanian Food Assistance Association (Test) (RFAAT)",False)
driver.find_element_by_id("pr_person_first_name").clear()
driver.find_element_by_id("pr_person_first_name").send_keys("John")
driver.find_element_by_id("pr_person_last_name").clear()
driver.find_element_by_id("pr_person_last_name").send_keys("Thompson")
driver.find_element_by_css_selector("img.ui-datepicker-trigger").click()
driver.find_element_by_link_text("7").click()
driver.find_element_by_id("pr_person_gender").send_keys("male")
driver.find_element_by_id("pr_person_occupation").clear()
driver.find_element_by_id("pr_person_occupation").send_keys("Social Worker")
driver.find_element_by_id("pr_person_email").clear()
driver.find_element_by_id("pr_person_email").send_keys("[email protected]")
driver.find_element_by_id("hrm_human_resource_job_title").clear()
driver.find_element_by_id("hrm_human_resource_job_title").send_keys("Distributor")
driver.find_element_by_id("hrm_human_resource_start_date").click()
driver.find_element_by_id("hrm_human_resource_start_date").clear()
driver.find_element_by_id("hrm_human_resource_start_date").send_keys("2012-04-17")
driver.find_element_by_id("gis_location_L0").send_keys("Romania")
driver.find_element_by_id("gis_location_street").clear()
driver.find_element_by_id("gis_location_street").send_keys("23 Petru St")
driver.find_element_by_id("gis_location_L3_ac").clear()
driver.find_element_by_id("gis_location_L3_ac").send_keys("Bucharest")
time.sleep(5)
driver.find_element_by_id("ui-menu-2-0").click()
driver.find_element_by_css_selector("input[type=\"submit\"]").click()
s3_debug("hrm002 test: Pass")
示例8: helper_inv_recv_shipment
def helper_inv_recv_shipment(self, user, recv_id, data):
"""
Helper method that will receive the shipment, adding the
totals that arrived
It will get the stock in the warehouse before and then after
and check that the stock levels have been properly increased
"""
s3db = current.s3db
db = current.db
rvtable = s3db.inv_recv
iitable = s3db.inv_inv_item
# First get the site_id
query = rvtable.id == recv_id
record = db(query).select(rvtable.site_id, limitby=(0, 1)).first()
site_id = record.site_id
# Now get all the inventory items for the site
query = iitable.site_id == site_id
before = db(query).select(orderby=iitable.id)
self.login(account=user, nexturl="inv/recv_process/%s" % recv_id)
query = iitable.site_id == site_id
after = db(query).select(orderby=iitable.id)
# Find the differences between the before and the after
changes = []
for a_rec in after:
found = False
for b_rec in before:
if a_rec.id == b_rec.id:
if a_rec.quantity != b_rec.quantity:
changes.append((a_rec.item_id, a_rec.item_pack_id, a_rec.quantity - b_rec.quantity))
found = True
break
if not found:
changes.append((a_rec.item_id, a_rec.item_pack_id, a_rec.quantity))
# changes now contains the list of changed or new records
# these should match the records received
# first check are the lengths the same?
self.assertTrue(
len(data) == len(changes),
"The number of changed inventory items (%s) doesn't match the number of items received (%s)."
% (len(changes), len(data)),
)
for line in data:
rec = line["record"]
found = False
for change in changes:
if (
rec.inv_track_item.item_id == change[0]
and rec.inv_track_item.item_pack_id == change[1]
and rec.inv_track_item.quantity == change[2]
):
found = True
break
if found:
s3_debug("%s accounted for." % line["text"])
else:
s3_debug("%s not accounted for." % line["text"])
示例9: login
def login(account="normal", nexturl=None):
""" Login to the system """
config = current.test_config
browser = config.browser
if isinstance(account,(list,tuple)):
email = account[0]
password = account[1]
if account == "normal":
email = "[email protected]"
password = "eden"
elif account == "admin":
email = "[email protected]"
password = "testing"
elif isinstance(account, (tuple,list)) and len(account) == 2:
email = account[0]
password = account[1]
else:
raise NotImplementedError
# If the user is already logged in no need to do anything so return
if browser.page_source.find("<a id=\"auth_menu_email\">%s</a>" % email) > 0:
# if the url is different then move to the new url
if not browser.current_url.endswith(nexturl):
url = "%s/%s" % (config.url, nexturl)
browser.get(url)
return
if nexturl:
url = "%s/default/user/login?_next=%s" % (config.url, nexturl)
else:
url = "%s/default/user/login" % config.url
browser.get(url)
# Login
elem = browser.find_element_by_id("auth_user_email")
elem.send_keys(email)
elem = browser.find_element_by_id("auth_user_password")
elem.send_keys(password)
elem = browser.find_element_by_xpath("//input[contains(@value,'Login')]")
elem.click()
# Check the result
try:
elem = browser.find_element_by_xpath("//div[@class='confirmation']")
except NoSuchElementException:
s3_debug("Login failed.. so registering account")
# Try registering
register(account)
else:
s3_debug(elem.text)
return True
示例10: hrm003
def hrm003():
config = current.test_config
browser = config.browser
driver = browser
driver.find_element_by_link_text("Staff & Volunteers").click()
driver.find_element_by_link_text("New Training Course").click()
driver.find_element_by_id("hrm_course_name").click()
driver.find_element_by_id("hrm_course_name").clear()
driver.find_element_by_id("hrm_course_name").send_keys("Emergency First Aid")
driver.find_element_by_css_selector("input[type=\"submit\"]").click()
driver.find_element_by_link_text("Home").click()
s3_debug("hrm003 test: Pass")
示例11: hrm006
def hrm006():
config = current.test_config
browser = config.browser
driver = browser
driver.find_element_by_xpath("//div[@id='facility_box']/a[4]/div").click()
driver.find_element_by_xpath("(//a[contains(text(),'Open')])[3]").click()
driver.find_element_by_link_text("Staff").click()
driver.find_element_by_id("select_from_registry").click()
driver.find_element_by_id("dummy_hrm_human_resource_person_id").clear()
w_autocomplete("Corn","hrm_human_resource_person","Cornelio da Cunha",False)
driver.find_element_by_css_selector("input[type=\"submit\"]").click()
driver.find_element_by_css_selector("span.S3menulogo").click()
driver.find_element_by_link_text("Home").click()
s3_debug("hrm006 test: Pass")
示例12: hrm007
def hrm007():
config = current.test_config
browser = config.browser
driver = browser
driver.find_element_by_link_text("Warehouse").click()
driver.find_element_by_link_text("List All").click()
driver.find_element_by_link_text("Open").click()
driver.find_element_by_link_text("Staff").click()
driver.find_element_by_id("select_from_registry").click()
w_autocomplete("Fel","hrm_human_resource_person","Felix Ximenes",False)
driver.find_element_by_css_selector("input[type=\"submit\"]").click()
driver.find_element_by_css_selector("span.S3menulogo").click()
driver.find_element_by_link_text("Home").click()
s3_debug("hrm007 test: Pass")
示例13: register
def register(account="normal"):
""" Register on the system """
config = current.test_config
browser = config.browser
# Load homepage
homepage()
if account == "normal":
first_name = "Test"
last_name = "User"
email = "[email protected]"
elif account == "admin":
first_name = "Admin"
last_name = "User"
email = "[email protected]"
else:
raise NotImplementedError
password = "eden"
# Register user
elem = browser.find_element_by_id("auth_user_first_name")
elem.send_keys(first_name)
elem = browser.find_element_by_id("auth_user_last_name")
elem.send_keys(last_name)
elem = browser.find_element_by_id("auth_user_email")
elem.send_keys(email)
elem = browser.find_element_by_id("auth_user_password")
elem.send_keys(password)
elem = browser.find_element_by_id("auth_user_password_two")
elem.send_keys(password)
elem = browser.find_element_by_xpath("//input[contains(@value,'Register')]")
elem.click()
# Check the result
try:
elem = browser.find_element_by_xpath("//div[@class='confirmation']")
except NoSuchElementException:
assert 0, "Registration unsuccesful"
else:
s3_debug(elem.text)
return True
# END =========================================================================
示例14: hrm005
def hrm005():
config = current.test_config
browser = config.browser
driver = browser
driver.find_element_by_link_text("Organizations").click()
driver.find_element_by_link_text("List All").click()
driver.find_element_by_link_text("Open").click()
driver.find_element_by_xpath("(//a[contains(text(),'Staff & Volunteers')])[2]").click()
driver.find_element_by_id("pr_person_first_name").send_keys("Herculano")
driver.find_element_by_id("pr_person_last_name").send_keys("Hugh")
driver.find_element_by_id("pr_person_date_of_birth").send_keys("1968-10-18")
driver.find_element_by_id("pr_person_gender").send_keys("male")
driver.find_element_by_id("pr_person_email").send_keys("[email protected]")
driver.find_element_by_id("hrm_human_resource_job_title").send_keys("Staff")
driver.find_element_by_css_selector('input[type="submit"]').click()
s3_debug("hrm005 test: Pass")
示例15: helper_inv_send
def helper_inv_send(self, user, data):
"""
@case: INV
@description: Functions which runs specific workflows for Inventory tes
@TestDoc: https://docs.google.com/spreadsheet/ccc?key=0AmB3hMcgB-3idG1XNGhhRG9QWF81dUlKLXpJaFlCMFE
@Test Wiki: http://eden.sahanafoundation.org/wiki/DeveloperGuidelines/Testing
"""
print "\n"
"""
Helper method to add a inv_send record by the given user
"""
self.login(account=user, nexturl="inv/send/create")
table = "inv_send"
result = self.create(table, data)
s3_debug("WB reference: %s" % self.helper_inv_send_get_ref(result))
return result