本文整理汇总了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'))