本文整理汇总了Python中geotrek.core.factories.TrailFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python TrailFactory.create方法的具体用法?Python TrailFactory.create怎么用?Python TrailFactory.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geotrek.core.factories.TrailFactory
的用法示例。
在下文中一共展示了TrailFactory.create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_show_topologies
# 需要导入模块: from geotrek.core.factories import TrailFactory [as 别名]
# 或者: from geotrek.core.factories.TrailFactory import create [as 别名]
def test_delete_show_topologies(self):
self.login()
path = PathFactory(name="PATH_AB", geom=LineString((0, 0), (4, 0)))
poi = POIFactory.create(name='POI', no_path=True)
poi.add_path(path, start=0.5, end=0.5)
trail = TrailFactory.create(name='Trail', no_path=True)
trail.add_path(path, start=0.1, end=0.2)
trek = TrekFactory.create(name='Trek', no_path=True)
trek.add_path(path, start=0.2, end=0.3)
service = ServiceFactory.create(no_path=True, type__name='ServiceType')
service.add_path(path, start=0.2, end=0.3)
signage = SignageFactory.create(name='Signage', no_path=True)
signage.add_path(path, start=0.2, end=0.2)
infrastructure = InfrastructureFactory.create(name='Infrastructure', no_path=True)
infrastructure.add_path(path, start=0.2, end=0.2)
intervention1 = InterventionFactory.create(topology=signage, name='Intervention1')
t = TopologyFactory.create(no_path=True)
t.add_path(path, start=0.2, end=0.5)
intervention2 = InterventionFactory.create(topology=t, name='Intervention2')
response = self.client.get(path.get_delete_url())
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'Different topologies are linked with this path')
self.assertContains(response, '<a href="/poi/%d/">POI</a>' % poi.pk)
self.assertContains(response, '<a href="/trail/%d/">Trail</a>' % trail.pk)
self.assertContains(response, '<a href="/trek/%d/">Trek</a>' % trek.pk)
self.assertContains(response, '<a href="/service/%d/">ServiceType</a>' % service.pk)
self.assertContains(response, '<a href="/signage/%d/">Signage</a>' % signage.pk)
self.assertContains(response, '<a href="/infrastructure/%d/">Infrastructure</a>' % infrastructure.pk)
self.assertContains(response, '<a href="/intervention/%d/">Intervention1</a>' % intervention1.pk)
self.assertContains(response, '<a href="/intervention/%d/">Intervention2</a>' % intervention2.pk)
示例2: test_delete_multiple_path
# 需要导入模块: from geotrek.core.factories import TrailFactory [as 别名]
# 或者: from geotrek.core.factories.TrailFactory import create [as 别名]
def test_delete_multiple_path(self):
path_1 = PathFactory.create(name="path_1", geom=LineString((0, 0), (4, 0)))
path_2 = PathFactory.create(name="path_2", geom=LineString((2, 2), (2, -2)))
poi = POIFactory.create(no_path=True, name="POI_1")
poi.add_path(path_1, start=0, end=0)
infrastructure = InfrastructureFactory.create(no_path=True, name="INFRA_1")
infrastructure.add_path(path_1, start=0, end=1)
signage = SignageFactory.create(no_path=True, name="SIGNA_1")
signage.add_path(path_1, start=0, end=1)
trail = TrailFactory.create(no_path=True, name="TRAIL_1")
trail.add_path(path_2, start=0, end=1)
service = ServiceFactory.create(no_path=True)
service.add_path(path_2, start=0, end=1)
InterventionFactory.create(topology=signage, name="INTER_1")
response = self.client.get(reverse('core:multiple_path_delete', args=['%s,%s' % (path_1.pk, path_2.pk)]))
self.assertIn("POI_1", response.content)
self.assertIn("INFRA_1", response.content)
self.assertIn("SIGNA_1", response.content)
self.assertIn("TRAIL_1", response.content)
self.assertIn("ServiceType", response.content)
self.assertIn("INTER_1", response.content)
response = self.client.post(reverse('core:multiple_path_delete', args=['%s,%s' % (path_1.pk, path_2.pk)]))
self.assertEqual(response.status_code, 302)
self.assertEqual(Path.objects.count(), 2)
self.assertEqual(Path.objects.filter(pk__in=[path_1.pk, path_2.pk]).count(), 0)
示例3: test_trail_helpers
# 需要导入模块: from geotrek.core.factories import TrailFactory [as 别名]
# 或者: from geotrek.core.factories.TrailFactory import create [as 别名]
def test_trail_helpers(self):
if not self.factory:
return # ignore abstract test
t = TrailFactory.create()
t2 = TrailFactory.create()
self.assertEquals(len(getattr(t, self.helper_name)), 0)
self.assertEquals(len(getattr(t2, self.helper_name)), 0)
p = PathFactory.create(trail=t)
l = self.factory.create(no_path=True)
l.add_path(p)
self.assertEquals(len(getattr(t, self.helper_name)), 1)
self.assertEquals(len(getattr(t2, self.helper_name)), 0)
self.assertEqual([o.pk for o in getattr(t, self.helper_name).all()],
[l.pk])
示例4: setUp
# 需要导入模块: from geotrek.core.factories import TrailFactory [as 别名]
# 或者: from geotrek.core.factories.TrailFactory import create [as 别名]
def setUp(self):
super(TrailKmlGPXTest, self).setUp()
self.user = UserFactory.create(is_staff=True, is_superuser=True)
self.client.force_login(self.user)
self.trail = TrailFactory.create(comments='exportable trail')
self.gpx_response = self.client.get(reverse('core:trail_gpx_detail', args=('en', self.trail.pk, 'slug')))
self.gpx_parsed = BeautifulSoup(self.gpx_response.content, 'lxml')
self.kml_response = self.client.get(reverse('core:trail_kml_detail', args=('en', self.trail.pk, 'slug')))
示例5: test_trail_helpers
# 需要导入模块: from geotrek.core.factories import TrailFactory [as 别名]
# 或者: from geotrek.core.factories.TrailFactory import create [as 别名]
def test_trail_helpers(self):
t = TrailFactory.create()
self.assertEqual(0, len(t.interventions))
p = PathFactory.create()
t.paths.add(p)
topo = TopologyFactory.create(no_path=True)
topo.add_path(p)
i = InterventionFactory(topology=topo)
self.assertEqual(1, len(t.interventions))
self.assertItemsEqual([i], t.interventions)
示例6: test_geom
# 需要导入模块: from geotrek.core.factories import TrailFactory [as 别名]
# 或者: from geotrek.core.factories.TrailFactory import create [as 别名]
def test_geom(self):
t = TrailFactory.create()
self.assertTrue(t.geom is None)
p = PathFactory.create()
t.paths.add(p)
self.assertFalse(t.geom is None)
示例7: test_trail_csv
# 需要导入模块: from geotrek.core.factories import TrailFactory [as 别名]
# 或者: from geotrek.core.factories.TrailFactory import create [as 别名]
def test_trail_csv(self):
p1 = PathFactory.create()
t1 = TrailFactory.create(no_path=True)
t1.add_path(p1)
self.assertEqual(p1.trails_csv_display, t1.name)