本文整理汇总了Python中geotrek.core.factories.TrailFactory类的典型用法代码示例。如果您正苦于以下问题:Python TrailFactory类的具体用法?Python TrailFactory怎么用?Python TrailFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TrailFactory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DenormalizedTrailTest
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: test_document_export
def test_document_export(self, get_attributes_html):
get_attributes_html.return_value = '<p>mock</p>'
trail = TrailFactory()
self.login()
with open(trail.get_map_image_path(), 'w') as f:
f.write('***' * 1000)
response = self.client.get(trail.get_document_url())
self.assertEqual(response.status_code, 200)
示例3: test_add_trail_from_existing_topology
def test_add_trail_from_existing_topology(self):
self.login()
trail = TrailFactory()
form_data = self.get_good_data()
form_data['topology'] = trail.serialize(with_pk=False)
response = self.client.post(Trail.get_add_url(), form_data)
self.assertEqual(response.status_code, 302) # success, redirects to detail view
p = re.compile(r"/trail/(\d+)/")
m = p.match(response['Location'])
new_pk = int(m.group(1))
new_trail = Trail.objects.get(pk=new_pk)
self.assertIn(trail, new_trail.trails.all())
示例4: test_delete_multiple_path
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)
示例5: test_delete_show_topologies
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)
示例6: test_trail_helpers
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])
示例7: setUp
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')))
示例8: test_trail_helpers
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)
示例9: DenormalizedTrailTest
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'))
示例10: test_detail_page
def test_detail_page(self):
self.login()
trail = TrailFactory()
response = self.client.get(trail.get_detail_url())
self.assertEqual(response.status_code, 200)
示例11: test_denormalized_path_trails
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'))
示例12: test_geom
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)
示例13: test_trail_csv
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)