本文整理汇总了Python中voter.models.VoterManager.delete_voter方法的典型用法代码示例。如果您正苦于以下问题:Python VoterManager.delete_voter方法的具体用法?Python VoterManager.delete_voter怎么用?Python VoterManager.delete_voter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类voter.models.VoterManager
的用法示例。
在下文中一共展示了VoterManager.delete_voter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_count_with_no_cookie
# 需要导入模块: from voter.models import VoterManager [as 别名]
# 或者: from voter.models.VoterManager import delete_voter [as 别名]
def test_count_with_no_cookie(self):
"""
This API should work even if person isn't signed in
:return:
"""
#######################################
# Check to see if there are 0 voters
response = self.client.get(self.voter_count_url)
json_data = json.loads(response.content.decode())
# Python3 solution? Problem is refused connection
# req = Request(self.voter_count_url)
# response = urlopen(req)
# json_data = response.read()
self.assertEqual('success' in json_data, True, "'success' expected in the json response, and not found")
self.assertEqual('voter_count' in json_data, True,
"'voter_count' expected in the voterCount json response")
self.assertEqual(
json_data['voter_count'], 0,
"success: {success} (voter_count '0' expected), voter_count: {voter_count}".format(
success=json_data['success'], voter_count=json_data['voter_count']))
#######################################
# Add 3 voters so we can check count again
voter_manager = VoterManager()
email1 = "[email protected]"
voter_manager.create_voter(
email=email1,
password="password123",
)
email2 = "[email protected]"
voter_manager.create_voter(
email=email2,
password="password123",
)
email3 = "[email protected]"
voter_manager.create_voter(
email=email3,
password="password123",
)
#######################################
# Check to see if there are 3 voters
response2 = self.client.get(self.voter_count_url)
json_data2 = json.loads(response2.content.decode())
self.assertEqual('success' in json_data2, True, "'success' expected in the json response, and not found")
self.assertEqual('voter_count' in json_data2, True,
"'voter_count' expected in the voterCount json response")
self.assertEqual(
json_data2['voter_count'], 3,
"success: {success} (voter_count '3' expected), voter_count: {voter_count}".format(
success=json_data2['success'], voter_count=json_data2['voter_count']))
#######################################
# Remove data for 3 voters
voter_manager.delete_voter(email1)
voter_manager.delete_voter(email2)
voter_manager.delete_voter(email3)
#######################################
# Check to see if there are 0 voters
response3 = self.client.get(self.voter_count_url)
json_data3 = json.loads(response3.content.decode())
self.assertEqual('success' in json_data, True, "'success' expected in the json response, and not found")
self.assertEqual('voter_count' in json_data3, True,
"'voter_count' expected in the voterCount json response")
self.assertEqual(
json_data3['voter_count'], 0,
"success: {success} (voter_count '0' expected - 2nd pass), voter_count: {voter_count}".format(
success=json_data3['success'], voter_count=json_data3['voter_count']))