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


Python TrailFactory.add_path方法代码示例

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

示例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'))
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:25,代码来源:test_views.py


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