コード例 #1
0
ファイル: test_views.py プロジェクト: isarchit/Geotrek-admin
 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
0
ファイル: test_views.py プロジェクト: makinacorpus/Geotrek
 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
0
ファイル: test_views.py プロジェクト: makinacorpus/Geotrek
 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)
コード例 #4
0
 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
0
ファイル: tests.py プロジェクト: masterdubs/Geotrek
    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])
コード例 #6
0
ファイル: test_views.py プロジェクト: makinacorpus/Geotrek
    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')))
コード例 #7
0
    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
0
ファイル: test_views.py プロジェクト: numahell/Geotrek-admin
 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)))
     POIFactory.create(paths=[(path_1, 0, 0)], name="POI_1")
     InfrastructureFactory.create(paths=[(path_1, 0, 1)], name="INFRA_1")
     signage = SignageFactory.create(paths=[(path_1, 0, 1)], name="SIGNA_1")
     TrailFactory.create(paths=[(path_2, 0, 1)], name="TRAIL_1")
     ServiceFactory.create(paths=[(path_2, 0, 1)])
     InterventionFactory.create(target=signage, name="INTER_1")
     response = self.client.get(reverse('core:multiple_path_delete', args=['%s,%s' % (path_1.pk, path_2.pk)]))
     self.assertContains(response, "POI_1")
     self.assertContains(response, "INFRA_1")
     self.assertContains(response, "SIGNA_1")
     self.assertContains(response, "TRAIL_1")
     self.assertContains(response, "Service type")
     self.assertContains(response, "INTER_1")
     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)
コード例 #9
0
    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)
コード例 #10
0
ファイル: intervention.py プロジェクト: Web5design/Geotrek
 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)
コード例 #11
0
 def test_trail_csv(self):
     p1 = PathFactory.create()
     t1 = TrailFactory.create(paths=[p1])
     self.assertEqual(p1.trails_csv_display, t1.name)
コード例 #12
0
ファイル: tests.py プロジェクト: leplatrem/Geotrek
 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
0
 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)
コード例 #14
0
ファイル: tests.py プロジェクト: Web5design/Geotrek
 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)
コード例 #15
0
ファイル: test_models.py プロジェクト: makinacorpus/Geotrek
 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)