本文整理匯總了Python中geotrek.core.factories.TrailFactory.add_path方法的典型用法代碼示例。如果您正苦於以下問題:Python TrailFactory.add_path方法的具體用法?Python TrailFactory.add_path怎麽用?Python TrailFactory.add_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類geotrek.core.factories.TrailFactory
的用法示例。
在下文中一共展示了TrailFactory.add_path方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DenormalizedTrailTest
# 需要導入模塊: from geotrek.core.factories import TrailFactory [as 別名]
# 或者: from geotrek.core.factories.TrailFactory import add_path [as 別名]
class DenormalizedTrailTest(AuthentFixturesTest):
def setUp(self):
self.trail1 = TrailFactory(no_path=True)
self.trail2 = TrailFactory(no_path=True)
self.path = PathFactory()
self.trail1.add_path(self.path)
self.trail2.add_path(self.path)
def test_path_and_trails_are_linked(self):
self.assertIn(self.trail1, self.path.trails.all())
self.assertIn(self.trail2, self.path.trails.all())
def login(self):
user = PathManagerFactory(password='booh')
success = self.client.login(username=user.username, password='booh')
self.assertTrue(success)
def test_denormalized_path_trails(self):
PathFactory.create_batch(size=50)
TrailFactory.create_batch(size=50)
self.login()
with self.assertNumQueries(LTE(15)):
self.client.get(reverse('core:path_json_list'))
def test_trails_are_shown_as_links_in_list(self):
self.login()
response = self.client.get(reverse('core:path_json_list'))
self.assertEqual(response.status_code, 200)
paths_json = json.loads(response.content)
trails_column = paths_json['aaData'][0][4]
self.assertTrue(trails_column == u'%s, %s' % (self.trail1.name_display, self.trail2.name_display) or
trails_column == u'%s, %s' % (self.trail2.name_display, self.trail1.name_display))
示例2: DenormalizedTrailTest
# 需要導入模塊: from geotrek.core.factories import TrailFactory [as 別名]
# 或者: from geotrek.core.factories.TrailFactory import add_path [as 別名]
class DenormalizedTrailTest(AuthentFixturesTest):
def setUp(self):
self.trail1 = TrailFactory(no_path=True)
self.trail2 = TrailFactory(no_path=True)
self.path = PathFactory()
self.trail1.add_path(self.path)
self.trail2.add_path(self.path)
def test_path_and_trails_are_linked(self):
self.assertIn(self.trail1, self.path.trails.all())
self.assertIn(self.trail2, self.path.trails.all())
def login(self):
user = PathManagerFactory(password='booh')
success = self.client.login(username=user.username, password='booh')
self.assertTrue(success)
def test_denormalized_path_trails(self):
PathFactory.create_batch(size=50)
TrailFactory.create_batch(size=50)
self.login()
with self.assertNumQueries(LTE(15)):
self.client.get(reverse('core:path_json_list'))