本文整理汇总了Python中testing.assert_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_equal函数的具体用法?Python assert_equal怎么用?Python assert_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert_request_buttons
def assert_request_buttons(self, tree, button_classes, button_text):
found_buttons = []
for button in tree.iter('button'):
T.assert_in(button.attrib['class'], button_classes)
T.assert_in(button.text, button_text)
found_buttons.append(button)
T.assert_equal(len(button_classes), len(found_buttons))
示例2: test_get_api_page
def test_get_api_page(self):
T.MockedSettings['api_app'] = {'port': 8043, 'servername': 'push.test.com'}
with mock.patch.dict(Settings, T.MockedSettings):
T.assert_equal(
RequestHandler.get_api_page("pushes"),
"http://push.test.com:8043/api/pushes"
)
示例3: assert_checklist_for_tags
def assert_checklist_for_tags(self, tags, requestid=None):
num_checks = 0
checks = []
# Gather reference checklists from the code
for tag in tags:
# While the tag name is 'search-backend', the checklist type
# is truncated to 'search'.
if tag == 'search-backend':
tag = 'search'
if tag not in checklist_reminders:
continue
plain_list = checklist_reminders[tag]
num_checks += len(plain_list)
checks += [(tag, check) for check in plain_list]
cleanup_tag = '%s-cleanup' % tag
cleanup_list = checklist_reminders[cleanup_tag]
num_checks += len(cleanup_list)
checks += [(cleanup_tag, check) for check in cleanup_list]
reqid = self.make_request_with_tags(tags, requestid)
checklists = self.get_checklists(reqid)
T.assert_equal(num_checks, len(checklists))
for check in checks:
T.assert_in((reqid, check[0], check[1]), checklists)
return reqid
示例4: test_process_queue_duplicate
def test_process_queue_duplicate(self):
with nested(
mock.patch("%s.core.git.GitQueue.update_request_failure" % __name__),
mock.patch("%s.core.git.GitQueue.update_request_successful" % __name__),
# This will fail, stop logging errors
mock.patch("%s.core.git.logging.error" % __name__),
mock.patch(
"%s.core.git.GitQueue._get_request_with_sha" % __name__,
return_value = {'id': 10, 'state': 'requested'}
),
self.mocked_update_request(self.fake_request, self.fake_request)
):
# GitQueue._get_request_with_sha returning a value means
# we have a duplicated request. This should trigger a
# failure
T.assert_equal(core.git.GitQueue.update_request_failure.call_count, 1)
T.assert_equal(core.git.GitQueue.update_request_successful.call_count, 0)
# Match the error message for duplicate revision. error_msg
# should be the last item of the first call object's *args list
# (from mock library).
T.assert_in(
"another request with the same revision sha",
core.git.GitQueue.update_request_failure.call_args_list[0][0][-1]
)
示例5: test_checklist_duplicate
def test_checklist_duplicate(self):
with fake_checklist_request():
# insert fake data from FakeDataMixin
fake_pushid = 2
self.insert_pushes()
self.insert_requests()
test1_request = self.get_requests_by_user('testuser1')[0]
test2_request = self.get_requests_by_user('testuser2')[0]
self.insert_pushcontent(test1_request['id'], fake_pushid)
self.insert_pushcontent(test2_request['id'], fake_pushid)
# insert fake checklist data
checklist_queries = []
for req in (test1_request, test2_request):
checklist_queries.append(db.push_checklist.insert({
'request': req['id'],
'type': 'search',
'target': 'prod'
}))
checklist_queries.append(db.push_checklist.insert({
'request': req['id'],
'type': 'search-cleanup',
'target': 'post-verify-prod'
}))
db.execute_transaction_cb(checklist_queries, on_db_return)
uri = "/checklist?id=%d" % fake_pushid
response = self.fetch(uri)
T.assert_equal(response.error, None)
T.assert_not_in("No checklist items for this push", response.body)
T.assert_not_equal(re.search("for testuser\d,testuser\d", response.body), None)
T.assert_in("After Certifying - Do In Prod", response.body)
示例6: test_checklist_single_search_tag
def test_checklist_single_search_tag(self):
with fake_checklist_request():
# insert fake data from FakeDataMixin
fake_pushid = 2
self.insert_pushes()
self.insert_requests()
test1_request = self.get_requests_by_user('testuser1')[0]
self.insert_pushcontent(test1_request['id'], fake_pushid)
# insert fake checklist data
checklist_queries = [
db.push_checklist.insert({
'request': test1_request['id'],
'type': 'search',
'target': 'prod'
}),
db.push_checklist.insert({
'request': test1_request['id'],
'type': 'search-cleanup',
'target': 'post-verify-prod'
}),
]
db.execute_transaction_cb(checklist_queries, on_db_return)
uri = "/checklist?id=%d" % fake_pushid
response = self.fetch(uri)
T.assert_equal(response.error, None)
T.assert_not_in("No checklist items for this push", response.body)
T.assert_not_in("multiple requests", response.body)
T.assert_in("for testuser1", response.body)
T.assert_in("After Certifying - Do In Prod", response.body)
示例7: test_get_repository_uri_basic
def test_get_repository_uri_basic(self):
T.MockedSettings["git"] = self.fake_settings
with mock.patch.dict(Settings, T.MockedSettings):
T.assert_equal(core.git.GitQueue._get_repository_uri("main_repository"),
"git://example/main_repository")
T.assert_equal(core.git.GitQueue._get_repository_uri("second_repository"),
"git://example/dev_directory/second_repository")
示例8: test_hoods_checklists
def test_hoods_checklists(self):
with fake_checklist_request():
# insert fake data from FakeDataMixin
fake_pushid = 2
self.insert_pushes()
self.insert_requests()
req = self.get_requests_by_user('testuser1')[0]
self.insert_pushcontent(req['id'], fake_pushid)
# insert fake checklist data
checklist_queries = []
checklist_items = (
{'request': req['id'], 'type': 'hoods', 'target': 'stage'},
{'request': req['id'], 'type': 'hoods', 'target': 'post-stage'},
{'request': req['id'], 'type': 'hoods', 'target': 'prod'},
{'request': req['id'], 'type': 'hoods-cleanup', 'target': 'post-verify-stage'},
)
for checklist_item in checklist_items:
checklist_queries.append(db.push_checklist.insert(checklist_item))
db.execute_transaction_cb(checklist_queries, on_db_return)
uri = "/checklist?id=%d" % fake_pushid
response = self.fetch(uri)
T.assert_equal(response.error, None)
T.assert_not_in("No checklist items for this push", response.body)
T.assert_in("Notify testuser1 to deploy Geoservices to stage", response.body)
T.assert_in("Notify testuser1 to deploy Geoservices to prod", response.body)
T.assert_in("Ask Search to force index distribution on stage for testuser1", response.body)
示例9: test_removerequest
def test_removerequest(self):
results = []
def on_db_return(success, db_results):
assert success
results.extend(db_results.fetchall())
with nested(
mock.patch.dict(db.Settings, T.MockedSettings),
mock.patch.object(
RemoveRequestServlet,
"get_current_user",
return_value="testuser"
)
):
results = []
db.execute_cb(db.push_pushcontents.select(), on_db_return)
num_results_before = len(results)
uri = "/removerequest?request=1&push=1"
response = self.fetch(uri)
T.assert_equal(response.error, None)
results = []
db.execute_cb(db.push_pushcontents.select(), on_db_return)
num_results_after = len(results)
T.assert_equal(num_results_after, num_results_before - 1, "Request removal failed.")
示例10: test_update_request_failure
def test_update_request_failure(self):
with nested(
mock.patch("%s.core.git.MailQueue.enqueue_user_email" % __name__),
mock.patch("%s.core.git.webhook_req" % __name__),
mock.patch("%s.core.git.logging.error" % __name__),
):
core.git.GitQueue.update_request_failure(self.fake_request, "fake failure")
T.assert_equal(core.git.MailQueue.enqueue_user_email.call_count, 1)
示例11: test_get_repository_uri_with_auth
def test_get_repository_uri_with_auth(self):
T.MockedSettings["git"] = self.fake_settings
T.MockedSettings["git"]["auth"] = "myuser:mypass"
with mock.patch.dict(Settings, T.MockedSettings):
T.assert_equal(core.git.GitQueue._get_repository_uri("main_repository"),
"git://myuser:[email protected]/main_repository")
T.assert_equal(core.git.GitQueue._get_repository_uri("second_repository"),
"git://myuser:[email protected]/dev_directory/second_repository")
示例12: test_update_request_successful
def test_update_request_successful(self):
with nested(
mock.patch("%s.core.git.MailQueue.enqueue_user_email" % __name__),
mock.patch("%s.core.git.webhook_req" % __name__)
):
core.git.GitQueue.update_request_successful(self.fake_request)
T.assert_equal(core.git.MailQueue.enqueue_user_email.call_count, 1)
T.assert_equal(core.git.webhook_req.call_count, 3)
示例13: test_escape
def test_escape(self):
T.assert_equal(
[k for k in self.d if self.ed[k] != self.escaped[k]],
[],
"EscapedDict values doesn't match with pre-computed valued",
)
T.assert_in("&", self.ed["amp"])
T.assert_not_in(">", self.ed["gt"])
示例14: test_create_request_bookmarklet
def test_create_request_bookmarklet(self):
with self.page(CreateRequestBookmarkletHandler) as response:
# We'll get a javascript as the body, just check some
# variable names/strings that we know is there in the
# script.
T.assert_equal(response.error, None)
T.assert_in("ticketNumberToURL", response.body)
T.assert_in("codeReview", response.body)
示例15: test_pushplans_and_search
def test_pushplans_and_search(self):
tag = ['pushplans']
orig_reqid = self.assert_checklist_for_tags(tag)
tags = ['pushplans', 'search-backend']
new_reqid = self.assert_checklist_for_tags(tags, orig_reqid)
T.assert_equal(orig_reqid, new_reqid)