本文整理汇总了Python中globaleaks.utils.token.Token.update方法的典型用法代码示例。如果您正苦于以下问题:Python Token.update方法的具体用法?Python Token.update怎么用?Python Token.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类globaleaks.utils.token.Token
的用法示例。
在下文中一共展示了Token.update方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_token_update_wrong_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import update [as 别名]
def test_token_update_wrong_answer(self):
token = Token('submission')
token.human_captcha = {'question': 'XXX','answer': 1}
token.update({'human_captcha_answer': 0})
# verify that the challenge is changed
self.assertNotEqual(token.human_captcha['question'], 'XXX')
示例2: test_token_update_right_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import update [as 别名]
def test_token_update_right_answer(self):
token = Token('submission')
token.human_captcha = {'question': '1 + 0','answer': 1}
token.proof_of_work = False
# validate with right value: OK
token.update({'human_captcha_answer': 1})
# verify that the challenge is marked as solved
self.assertFalse(token.human_captcha)
示例3: test_token_usage_limit
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import update [as 别名]
def test_token_usage_limit(self):
token = Token('submission')
token.solve()
token.human_captcha = {'question': 'XXX', 'answer': 1, 'solved': False}
# validate with right value: OK
token.update({'human_captcha_answer': 1})
for i in range(0, token.MAX_USES-1):
token.use()
# validate with right value but with no additional
# attempts available: FAIL
self.assertRaises(errors.TokenFailure, token.use)
示例4: test_token_uses_limit
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import update [as 别名]
def test_token_uses_limit(self):
token = Token('submission')
token.human_captcha = False
token.proof_of_work = False
# validate with right value: OK
token.update({'human_captcha_answer': 1})
for i in range(0, token.MAX_USES):
token.use()
# validate with right value but with no additional
# attempts available: FAIL
self.assertRaises(
errors.TokenFailure,
token.use
)
示例5: test_token_update_right_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import update [as 别名]
def test_token_update_right_answer(self):
token = Token('submission')
token.solve()
token.human_captcha = {'question': '1 + 0', 'answer': 1, 'solved': False}
# validate with right value: OK
self.assertTrue(token.update({'human_captcha_answer': 1}))
# verify that the challenge is marked as solved
self.assertTrue(token.human_captcha['solved'])
示例6: test_proof_of_work_right_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import update [as 别名]
def test_proof_of_work_right_answer(self):
token = Token('submission')
token.solve()
# Note, this solution works with two '00' at the end, if the
# difficulty changes, also this dummy value has to.
token.proof_of_work = {'question': "7GJ4Sl37AEnP10Zk9p7q", 'solved': False}
# validate with right value: OK
self.assertTrue(token.update({'proof_of_work_answer': 26}))
token.use()
示例7: test_proof_of_work_right_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import update [as 别名]
def test_proof_of_work_right_answer(self):
token = Token('submission')
difficulty = {
'human_captcha': False,
'graph_captcha': False,
'proof_of_work': False
}
token.generate_token_challenge(difficulty)
token = TokenList.get(token.id)
# Note, this solution works with two '00' at the end, if the
# difficulty changes, also this dummy value has to.
token.proof_of_work = { 'question': "7GJ4Sl37AEnP10Zk9p7q" }
# validate with right value: OK
self.assertTrue(token.update({'proof_of_work_answer': 0}))
示例8: test_proof_of_work_right_answer
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import update [as 别名]
def test_proof_of_work_right_answer(self):
# This is at the beginning
event.EventTrackQueue.reset()
token = Token('submission')
difficulty = {
'human_captcha': False,
'graph_captcha': False,
'proof_of_work': False
}
token.generate_token_challenge(difficulty)
token = TokenList.get(token.id)
# Note, this solution works with two '00' at the end, if the
# difficulty changes, also this dummy value has to.
token.proof_of_work = { 'question': "7GJ4Sl37AEnP10Zk9p7q" }
# validate with right value: OK
self.assertFalse(token.update({'proof_of_work_answer': 26}))
# verify that the challenge is marked as solved
self.assertFalse(token.proof_of_work)