當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。