本文整理汇总了Python中models.Customer.create方法的典型用法代码示例。如果您正苦于以下问题:Python Customer.create方法的具体用法?Python Customer.create怎么用?Python Customer.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Customer
的用法示例。
在下文中一共展示了Customer.create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_user_creation_and_editing
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import create [as 别名]
def test_user_creation_and_editing(self):
test_user = users.User('[email protected]')
new = Customer.create(url='test', user=test_user)
self.assertTrue(new)
self.assertEqual(Customer.get_points_for('test').__len__(), 0)
self.assertTrue(Point.create_point(new, dict(lat=63.345, lon= -4.23)))
self.assertEqual(Customer.get_points_for('test').__len__(), 1)
self.assertRaises(Exception, Customer.create, url='test', user=users.User('[email protected]'))
self.assertRaises(Exception, Customer.create, url='TeSt', user=users.User('[email protected]'))
self.assertRaises(Exception, Customer.create, url='new_test', user=test_user)
renew = Customer.create(url='newtest', user=test_user)
self.assertTrue(renew)
self.assertEqual(Customer.get_points_for('newtest').__len__(), 1)
self.assertTrue(Point.create_point(renew, dict(lat=43.345, lon= -3.23)))
self.assertEqual(Customer.get_points_for('newtest').__len__(), 2)
示例2: create_customer
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import create [as 别名]
def create_customer(url, user):
return Customer.create(url, user)
示例3: BeautifulSoup
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import create [as 别名]
page = requests.get(url)
print "2"
bf = BeautifulSoup(page.content)
print "3"
review_list = bf.find_all('div',{'class','criticinfo'})
#print "getting " + len(review_list) + " customer info"
for review in review_list:
info = review.find('a')
customer_name = info.text
customer_href = info.get('href')
print "try to save customer " + customer_name
try:
customer = Customer.create(
name = customer_name,
href = customer_href,
fetched = False)
customer.save()
print "customer saved"
customer_movie = Customer_Movie.create(
customer = customer,
movie = movie)
customer_movie.save()
print "customer_movie saved"
except Exception, e:
print "exception when saving customer"
movie.fetched = True;
movie.save()