本文整理匯總了Python中geotrek.core.factories.TrailFactory.serialize方法的典型用法代碼示例。如果您正苦於以下問題:Python TrailFactory.serialize方法的具體用法?Python TrailFactory.serialize怎麽用?Python TrailFactory.serialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類geotrek.core.factories.TrailFactory
的用法示例。
在下文中一共展示了TrailFactory.serialize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_add_trail_from_existing_topology
# 需要導入模塊: from geotrek.core.factories import TrailFactory [as 別名]
# 或者: from geotrek.core.factories.TrailFactory import serialize [as 別名]
def test_add_trail_from_existing_topology(self):
self.login()
trail = TrailFactory()
form_data = self.get_good_data()
form_data['topology'] = trail.serialize(with_pk=False)
response = self.client.post(Trail.get_add_url(), form_data)
self.assertEqual(response.status_code, 302) # success, redirects to detail view
p = re.compile(r"/trail/(\d+)/")
m = p.match(response['Location'])
new_pk = int(m.group(1))
new_trail = Trail.objects.get(pk=new_pk)
self.assertIn(trail, new_trail.trails.all())