Esempio n. 1
0
 def test_pois_types(self):
     trek = TrekWithPOIsFactory.create()
     type0 = trek.pois[0].type
     type1 = trek.pois[1].type
     self.assertEqual(2, len(trek.poi_types))
     self.assertIn(type0, trek.poi_types)
     self.assertIn(type1, trek.poi_types)
Esempio n. 2
0
 def test_kml(self):
     trek = TrekWithPOIsFactory.create()
     url = reverse('trekking:trek_kml_detail', kwargs={'pk': trek.pk})
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response['Content-Type'],
                      'application/vnd.google-earth.kml+xml')
Esempio n. 3
0
 def test_pois_types(self):
     trek = TrekWithPOIsFactory.create()
     type0 = trek.pois[0].type
     type1 = trek.pois[1].type
     self.assertEqual(2, len(trek.poi_types))
     self.assertIn(type0, trek.poi_types)
     self.assertIn(type1, trek.poi_types)
Esempio n. 4
0
 def test_kml_coordinates_should_be_3d(self):
     trek = TrekWithPOIsFactory.create()
     kml = trek.kml()
     parsed = BeautifulSoup(kml)
     for placemark in parsed.findAll('placemark'):
         coordinates = placemark.find('coordinates')
         tuples = [s.split(',') for s in coordinates.string.split(' ')]
         self.assertTrue(all([len(i) == 3 for i in tuples]))
Esempio n. 5
0
 def test_kml_coordinates_should_be_3d(self):
     trek = TrekWithPOIsFactory.create()
     kml = trek.kml()
     parsed = BeautifulSoup(kml)
     for placemark in parsed.findAll('placemark'):
         coordinates = placemark.find('coordinates')
         tuples = [s.split(',') for s in coordinates.string.split(' ')]
         self.assertTrue(all([len(i) == 3 for i in tuples]))
Esempio n. 6
0
 def test_trek_export_poi_list_limit(self, mocked_prepare, mocked_attributes):
     trek = TrekWithPOIsFactory.create()
     self.assertEqual(len(trek.pois), 2)
     view = trekking_views.TrekDocumentPublic()
     view.object = trek
     view.request = RequestFactory().get('/')
     view.kwargs = {}
     view.kwargs[view.pk_url_kwarg] = trek.pk
     context = view.get_context_data()
     self.assertEqual(len(context['pois']), 1)
Esempio n. 7
0
 def test_trek_export_poi_list_limit(self, mocked_prepare,
                                     mocked_attributes):
     trek = TrekWithPOIsFactory.create()
     self.assertEqual(len(trek.pois), 2)
     view = trekking_views.TrekDocumentPublic()
     view.object = trek
     view.request = RequestFactory().get('/')
     view.kwargs = {}
     view.kwargs[view.pk_url_kwarg] = trek.pk
     context = view.get_context_data()
     self.assertEqual(len(context['pois']), 1)
Esempio n. 8
0
    def test_pois_geojson(self):
        trek = TrekWithPOIsFactory.create()
        self.assertEqual(len(trek.pois), 2)
        poi = trek.pois[0]
        AttachmentFactory.create(obj=poi, attachment_file=get_dummy_uploaded_image())
        self.assertNotEqual(poi.thumbnail, None)

        url = reverse('trekking:trek_poi_geojson', kwargs={'pk': trek.pk})
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        poislayer = json.loads(response.content)
        poifeature = poislayer['features'][0]
        self.assertTrue('serializable_thumbnail' in poifeature['properties'])
Esempio n. 9
0
    def test_pois_geojson(self):
        trek = TrekWithPOIsFactory.create()
        self.assertEqual(len(trek.pois), 2)
        poi = trek.pois[0]
        AttachmentFactory.create(obj=poi,
                                 attachment_file=get_dummy_uploaded_image())
        self.assertNotEqual(poi.thumbnail, None)
        self.assertEqual(len(trek.pois), 2)

        url = reverse('trekking:trek_poi_geojson', kwargs={'pk': trek.pk})
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        poislayer = json.loads(response.content)
        poifeature = poislayer['features'][0]
        self.assertTrue('thumbnail' in poifeature['properties'])
Esempio n. 10
0
    def setUp(self):
        self.login()

        self.trek = TrekWithPOIsFactory.create()
        self.trek.description_en = 'Nice trek'
        self.trek.description_it = 'Bonnito iti'
        self.trek.description_fr = 'Jolie rando'
        self.trek.save()

        for poi in self.trek.pois.all():
            poi.description_it = poi.description
            poi.save()

        url = reverse('trekking:trek_gpx_detail', kwargs={'pk': self.trek.pk})
        self.response = self.client.get(url, HTTP_ACCEPT_LANGUAGE='it-IT')
        self.parsed = BeautifulSoup(self.response.content)
Esempio n. 11
0
    def setUp(self):
        self.login()

        self.trek = TrekWithPOIsFactory.create()
        self.trek.description_en = 'Nice trek'
        self.trek.description_it = 'Bonnito iti'
        self.trek.description_fr = 'Jolie rando'
        self.trek.save()

        for poi in self.trek.pois.all():
            poi.description_it = poi.description
            poi.save()

        url = '/api/it/treks/{pk}/slug.gpx'.format(pk=self.trek.pk)
        self.response = self.client.get(url)
        self.parsed = BeautifulSoup(self.response.content)
Esempio n. 12
0
    def test_pois_geojson(self):
        trek = TrekWithPOIsFactory.create(published=True)
        self.assertEqual(len(trek.pois), 2)
        poi = trek.pois[0]
        poi.published = True
        poi.save()
        AttachmentFactory.create(obj=poi, attachment_file=get_dummy_uploaded_image())
        self.assertNotEqual(poi.thumbnail, None)
        self.assertEqual(len(trek.pois), 2)

        url = '/api/en/treks/{pk}/pois.geojson'.format(pk=trek.pk)
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        poislayer = json.loads(response.content)
        poifeature = poislayer['features'][0]
        self.assertTrue('thumbnail' in poifeature['properties'])
Esempio n. 13
0
    def setUp(self):
        self.login()

        self.trek = TrekWithPOIsFactory.create()
        self.trek.description_en = 'Nice trek'
        self.trek.description_it = 'Bonnito iti'
        self.trek.description_fr = 'Jolie rando'
        self.trek.save()

        for poi in self.trek.pois.all():
            poi.description_it = poi.description
            poi.save()

        url = reverse('trekking:trek_gpx_detail', kwargs={'pk': self.trek.pk})
        self.response = self.client.get(url, HTTP_ACCEPT_LANGUAGE='it-IT')
        self.parsed = BeautifulSoup(self.response.content)
Esempio n. 14
0
    def test_gpx(self):
        trek = TrekWithPOIsFactory.create()
        trek.description_en = 'Nice trek'
        trek.description_it = 'Bonnito iti'
        trek.description_fr = 'Jolie rando'
        trek.save()

        url = reverse('trekking:trek_gpx_detail', kwargs={'pk': trek.pk})
        response = self.client.get(url, HTTP_ACCEPT_LANGUAGE='it-IT')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], 'application/gpx+xml')

        parsed = BeautifulSoup(response.content)
        self.assertEqual(len(parsed.findAll('rte')), 1)
        self.assertEqual(len(parsed.findAll('rtept')), 2)
        route = parsed.findAll('rte')[0]
        description = route.find('desc').string
        self.assertTrue(description.startswith(trek.description_it))
Esempio n. 15
0
 def test_kml(self):
     trek = TrekWithPOIsFactory.create()
     url = reverse('trekking:trek_kml_detail', kwargs={'pk': trek.pk})
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response['Content-Type'], 'application/vnd.google-earth.kml+xml')
Esempio n. 16
0
 def test_kml(self):
     trek = TrekWithPOIsFactory.create()
     url = '/api/en/treks/{pk}/slug.kml'.format(pk=trek.pk)
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response['Content-Type'], 'application/vnd.google-earth.kml+xml')