Exemplo n.º 1
0
    def test_pois_geojson(self):
        trek = TrekFactory.create(no_path=True)
        p1 = PathFactory.create(geom=LineString((0, 0, 0), (4, 4, 2)))
        poi = POIFactory(no_path=True)
        trek.add_path(p1, start=0.5, end=1.0)
        poi.add_path(p1, start=0.6, end=0.6)
        AttachmentFactory.create(obj=poi, attachment_file=get_dummy_uploaded_image())
        self.assertNotEqual(poi.thumbnail, None)
        self.assertEqual(len(trek.pois), 1)

        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'])
Exemplo n.º 2
0
 def test_remove_thumbnails(self):
     output = StringIO()
     self.content = POIFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID)
     self.picture = AttachmentFactory(
         content_object=self.content,
         attachment_file=get_dummy_uploaded_image())
     self.assertIsNotNone(self.content.thumbnail)
     self.assertTrue(os.path.exists(self.picture.attachment_file.path))
     self.assertTrue(
         os.path.exists("{path}.120x120_q85_crop.png".format(
             path=self.picture.attachment_file.path)))
     self.assertEqual(
         Thumbnail.objects.first().name,
         "{name}.120x120_q85_crop.png".format(
             name=self.picture.attachment_file.name))
     call_command('remove_thumbnails', stdout=output)
     self.assertTrue(os.path.exists(self.picture.attachment_file.path))
     self.assertFalse(
         os.path.exists("{name}.120x120_q85_crop.png".format(
             name=self.picture.attachment_file.path)))
     self.assertEqual(Thumbnail.objects.count(), 0)
Exemplo n.º 3
0
 def setUp(self):
     self.content = POIFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID)
     self.picture = AttachmentFactory(
         content_object=self.content,
         attachment_file=get_dummy_uploaded_image())