当前位置: 首页>>代码示例>>Python>>正文


Python Customer.create方法代码示例

本文整理汇总了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)
开发者ID:dlokesh,项目名称:mappr,代码行数:19,代码来源:customer_model_tests.py

示例2: create_customer

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import create [as 别名]
def create_customer(url, user):
    return Customer.create(url, user)
开发者ID:dlokesh,项目名称:mappr,代码行数:4,代码来源:gateway.py

示例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()
开发者ID:bh1091,项目名称:RTBD_Project,代码行数:34,代码来源:movie_to_customer.py


注:本文中的models.Customer.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。