Exemplo n.º 1
0
    def setUpClass(cls):
        super(SyncMobileTreksTest, cls).setUpClass()
        cls.portal_a = TargetPortalFactory()
        cls.portal_b = TargetPortalFactory()

        cls.trek_1 = TrekWithPublishedPOIsFactory.create()
        cls.trek_2 = TrekWithPublishedPOIsFactory.create(
            portals=(cls.portal_a, ))
        cls.trek_3 = TrekWithPublishedPOIsFactory.create(
            portals=(cls.portal_b, ))

        cls.attachment_1 = AttachmentFactory.create(
            content_object=cls.trek_1,
            attachment_file=get_dummy_uploaded_image())
        cls.poi_1 = POI.objects.first()
        cls.attachment_poi_image_1 = AttachmentFactory.create(
            content_object=cls.poi_1,
            attachment_file=get_dummy_uploaded_image())
        cls.attachment_poi_image_2 = AttachmentFactory.create(
            content_object=cls.poi_1,
            attachment_file=get_dummy_uploaded_image())
        cls.attachment_poi_file = AttachmentFactory.create(
            content_object=cls.poi_1,
            attachment_file=get_dummy_uploaded_file())
        translation.deactivate()
Exemplo n.º 2
0
 def test_the_starred_picture_is_taken_among_attachments(self):
     self.add_attachment(attachment=get_dummy_uploaded_image())
     starred = self.add_attachment(attachment=get_dummy_uploaded_image())
     self.add_attachment(attachment=get_dummy_uploaded_image())
     starred.starred = True
     starred.save()
     self.assertEqual(len(self.trek.attachments), 4)
     self.assertEqual(len(self.trek.pictures), 3)
     self.assertTrue(starred.attachment_file.name in self.trek.thumbnail.name)
Exemplo n.º 3
0
    def setUp(self):
        self.source_a = RecordSourceFactory()
        self.source_b = RecordSourceFactory()

        self.portal_a = TargetPortalFactory()
        self.portal_b = TargetPortalFactory()
        information_desks = InformationDeskFactory.create()
        self.trek_1 = TrekWithPublishedPOIsFactory.create(
            sources=(self.source_a, ),
            portals=(self.portal_b, ),
            published=True)
        self.trek_1.information_desks.add(information_desks)
        self.attachment_1 = AttachmentFactory.create(
            content_object=self.trek_1,
            attachment_file=get_dummy_uploaded_image())
        self.trek_2 = TrekFactory.create(sources=(self.source_b, ),
                                         published=True)
        self.trek_3 = TrekFactory.create(portals=(self.portal_b,
                                                  self.portal_a),
                                         published=True)
        self.trek_4 = TrekFactory.create(portals=(self.portal_a, ),
                                         published=True)

        self.poi_1 = trek_models.POI.objects.first()
        self.attachment_poi_image_1 = AttachmentFactory.create(
            content_object=self.poi_1,
            attachment_file=get_dummy_uploaded_image())
        self.attachment_poi_image_2 = AttachmentFactory.create(
            content_object=self.poi_1,
            attachment_file=get_dummy_uploaded_image())
        self.attachment_poi_file = AttachmentFactory.create(
            content_object=self.poi_1,
            attachment_file=get_dummy_uploaded_file())

        infrastructure = InfrastructureFactory.create(no_path=True,
                                                      name="INFRA_1")
        infrastructure.add_path(self.trek_1.paths.first(), start=0, end=0)
        signage = SignageFactory.create(no_path=True, name="SIGNA_1")
        signage.add_path(self.trek_1.paths.first(), start=0, end=0)
        SensitiveAreaFactory.create(published=True)
        self.touristic_content = TouristicContentFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID,
            published=True)
        self.touristic_event = TouristicEventFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID,
            published=True)
        self.attachment_touristic_content = AttachmentFactory.create(
            content_object=self.touristic_content,
            attachment_file=get_dummy_uploaded_image())
        self.attachment_touristic_event = AttachmentFactory.create(
            content_object=self.touristic_event,
            attachment_file=get_dummy_uploaded_image())
Exemplo n.º 4
0
    def setUp(self):
        self.user = SuperUserFactory.create(password='******')
        self.content = POIFactory.create(geom='SRID=%s;POINT(1 1)' %
                                         settings.SRID)

        self.picture = AttachmentFactory(
            content_object=self.content,
            attachment_file=get_dummy_uploaded_image(),
        )
        self.trek = TrekFactory.create(
            geom='SRID=%s;LINESTRING(0 0, 1 0, 2 0)' % settings.SRID)
        self.picture_2 = AttachmentFactory(
            content_object=self.trek,
            attachment_file=get_dummy_uploaded_image(),
        )
Exemplo n.º 5
0
    def setUpClass(cls):
        super(SyncMobileTreksTest, cls).setUpClass()
        cls.portal_a = TargetPortalFactory()
        cls.portal_b = TargetPortalFactory()
        picto_desk = get_dummy_uploaded_image()
        information_desk_type = InformationDeskTypeFactory.create(
            pictogram=picto_desk)
        cls.info_desk = InformationDeskFactory.create(
            type=information_desk_type)
        info_desk_no_picture = InformationDeskFactory.create(photo=None)

        cls.trek_1 = TrekWithPublishedPOIsFactory.create()
        cls.trek_1.information_desks.set((cls.info_desk, info_desk_no_picture))
        cls.trek_2 = TrekWithPublishedPOIsFactory.create(
            portals=(cls.portal_a, ))
        cls.trek_3 = TrekWithPublishedPOIsFactory.create(
            portals=(cls.portal_b, ))
        cls.trek_4 = TrekFactory.create()
        OrderedTrekChild.objects.create(parent=cls.trek_1,
                                        child=cls.trek_4,
                                        order=1)
        cls.desk = InformationDeskFactory.create()

        cls.trek_4.information_desks.add(cls.desk)

        cls.attachment_1 = AttachmentFactory.create(
            content_object=cls.trek_1,
            attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=cls.trek_1,
                                 attachment_file=get_dummy_uploaded_image())

        cls.poi_1 = cls.trek_1.published_pois.first()
        cls.attachment_poi_image_1 = AttachmentFactory.create(
            content_object=cls.poi_1,
            attachment_file=get_dummy_uploaded_image())
        cls.attachment_poi_image_2 = AttachmentFactory.create(
            content_object=cls.poi_1,
            attachment_file=get_dummy_uploaded_image())
        cls.attachment_poi_file = AttachmentFactory.create(
            content_object=cls.poi_1,
            attachment_file=get_dummy_uploaded_file())
        cls.attachment_trek_image = AttachmentFactory.create(
            content_object=cls.trek_4,
            attachment_file=get_dummy_uploaded_image())

        cls.touristic_content = TouristicContentFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID,
            published=True)
        cls.touristic_event = TouristicEventFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID,
            published=True)
        cls.attachment_content_1 = AttachmentFactory.create(
            content_object=cls.touristic_content,
            attachment_file=get_dummy_uploaded_image())
        cls.attachment_event_1 = AttachmentFactory.create(
            content_object=cls.touristic_event,
            attachment_file=get_dummy_uploaded_image())
        translation.deactivate()
Exemplo n.º 6
0
    def _build_object(self):
        polygon = 'SRID=%s;MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))' % settings.SRID
        self.city = zoning_factories.CityFactory(geom=polygon)
        self.district = zoning_factories.DistrictFactory(geom=polygon)

        self.content = self.factory(geom='SRID=%s;POINT(1 1)' % settings.SRID)

        self.picture = common_factories.AttachmentFactory(
            content_object=self.content,
            attachment_file=get_dummy_uploaded_image())
        self.document = common_factories.AttachmentFactory(
            content_object=self.content,
            attachment_file=get_dummy_uploaded_document())
        self.video = common_factories.AttachmentFactory(
            content_object=self.content,
            attachment_file='',
            attachment_video=
            'http://www.youtube.com/embed/Jm3anSjly0Y?wmode=opaque')
        self.video_detected = detect_backend(self.video.attachment_video)

        self.theme = common_factories.ThemeFactory()
        self.content.themes.add(self.theme)
        self.source = common_factories.RecordSourceFactory()
        self.content.source.add(self.source)

        self.portal = common_factories.TargetPortalFactory()
        self.content.portal.add(self.portal)

        path = core_factories.PathFactory(
            geom='SRID=%s;LINESTRING(0 10, 10 10)' % settings.SRID)
        self.trek = trekking_factories.TrekFactory(no_path=True)
        self.trek.add_path(path)
        self.poi = trekking_factories.POIFactory(no_path=True)
        self.poi.add_path(path, start=0.5, end=0.5)
Exemplo n.º 7
0
    def test_sync_settings_with_picto_svg(self):
        output = BytesIO()
        practice = PracticeFactory.create(
            pictogram=get_dummy_uploaded_image_svg())
        information_desk_type = InformationDeskTypeFactory.create(
            pictogram=get_dummy_uploaded_image())
        InformationDeskFactory.create(type=information_desk_type)
        pictogram_png = practice.pictogram.url.replace('.svg', '.png')
        pictogram_desk_png = information_desk_type.pictogram.url
        management.call_command('sync_mobile',
                                'tmp',
                                url='http://localhost:8000',
                                skip_tiles=True,
                                verbosity=2,
                                stdout=output)
        for lang in settings.MODELTRANSLATION_LANGUAGES:
            with open(os.path.join('tmp', lang, 'settings.json'), 'r') as f:
                settings_json = json.load(f)
                self.assertEquals(len(settings_json), 2)
                self.assertEqual(len(settings_json['data']), 16)
                self.assertEqual(
                    settings_json['data'][4]['values'][0]['pictogram'],
                    pictogram_png)
                self.assertEqual(
                    settings_json['data'][9]['values'][0]['pictogram'],
                    pictogram_desk_png)

        image_practice = Image.open(
            os.path.join('tmp', 'nolang', pictogram_png[1:]))
        image_desk = Image.open(
            os.path.join('tmp', 'nolang', pictogram_desk_png[1:]))
        self.assertEqual(image_practice.size, (32, 32))
        self.assertEqual(image_desk.size, (32, 32))
        self.assertIn('en/settings.json', output.getvalue())
Exemplo n.º 8
0
class TouristicContentType2Factory(factory.django.DjangoModelFactory):
    class Meta:
        model = models.TouristicContentType2

    label = "Type2"
    category = factory.SubFactory(TouristicContentCategoryFactory)
    pictogram = get_dummy_uploaded_image('touristiccontent-type2.png')
Exemplo n.º 9
0
class ServiceTypeFactory(factory.DjangoModelFactory):
    class Meta:
        model = models.ServiceType

    name = "Service type"
    pictogram = get_dummy_uploaded_image('service-type.png')
    published = True
Exemplo n.º 10
0
    def test_upload(self):
        path = PathFactory(length=1)
        response = self.client.get(path.get_update_url())

        f = get_dummy_uploaded_image()
        data = {
            'filetype': FileTypeFactory().pk,
            'title': 'title1',
            'legend': 'legend1',
            'attachment_file': f,
        }

        response = self.client.post(add_url_for_obj(path), data=data)
        self.assertEquals(response.status_code, 302)

        att = Attachment.objects.attachments_for_object(path).get()
        self.assertEqual(att.title, data['title'])
        self.assertEqual(att.legend, data['legend'])
        self.assertEqual(att.filetype.pk, data['filetype'])

        f.open()
        self.assertEqual(att.attachment_file.readlines(), f.readlines())

        # Check that if title is given, filename is title
        self.assertTrue(att.attachment_file.name, 'title1')

        # Check that if no title is give, filename is original name
        data['title'] = ''
        response = self.client.post(add_url_for_obj(path), data=data)
        att = Attachment.objects.attachments_for_object(path)[0]
        self.assertTrue(att.attachment_file.name, 'image')
Exemplo n.º 11
0
 def setUp(self):
     super(SyncTestPdf, self).setUp()
     self.trek_5 = TrekFactory.create(practice=self.practice_trek, portals=(self.portal_a,),
                                      published=True)
     filetype_topoguide = FileTypeFactory.create(type='Topoguide')
     AttachmentFactory.create(content_object=self.trek_5, attachment_file=get_dummy_uploaded_image(),
                              filetype=filetype_topoguide)
Exemplo n.º 12
0
class DataSourceFactory(factory.Factory):
    FACTORY_FOR = models.DataSource

    title = factory.Sequence(lambda n: u"DataSource %s" % n)
    url = factory.Sequence(lambda n: u"http://%s.com" % n)
    type = models.DATA_SOURCE_TYPES.GEOJSON
    pictogram = get_dummy_uploaded_image()
Exemplo n.º 13
0
    def _build_object(self):
        polygon = 'SRID=%s;MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))' % settings.SRID
        self.city = zoning_factories.CityFactory(geom=polygon)
        self.district = zoning_factories.DistrictFactory(geom=polygon)
        self.portal = common_factories.TargetPortalFactory()
        self.theme = common_factories.ThemeFactory()

        self.content = self.factory(geom='SRID=%s;POINT(1 1)' % settings.SRID,
                                    portals=[self.portal],
                                    themes=[self.theme])

        self.picture = common_factories.AttachmentFactory(
            content_object=self.content,
            attachment_file=get_dummy_uploaded_image())
        self.document = common_factories.AttachmentFactory(
            content_object=self.content,
            attachment_file=get_dummy_uploaded_document())

        self.content.themes.add(self.theme)
        self.source = common_factories.RecordSourceFactory()
        self.content.source.add(self.source)

        self.content.portal.add(self.portal)
        if settings.TREKKING_TOPOLOGY_ENABLED:
            path = core_factories.PathFactory(
                geom='SRID=%s;LINESTRING(0 10, 10 10)' % settings.SRID)
            self.trek = trekking_factories.TrekFactory(paths=[path])
            self.poi = trekking_factories.POIFactory(paths=[(path, 0.5, 0.5)])
        else:
            self.trek = trekking_factories.TrekFactory(
                geom='SRID=%s;LINESTRING(0 10, 10 10)' % settings.SRID)
            self.poi = trekking_factories.POIFactory(
                geom='SRID=%s;POINT(0 5)' % settings.SRID)
Exemplo n.º 14
0
class LevelFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = models.Level

    name = "Level"
    description = "<p>Description</p>"
    pictogram = get_dummy_uploaded_image('level.png')
Exemplo n.º 15
0
    def setUp(self):
        self.login()

        polygon = 'SRID=%s;MULTIPOLYGON(((700000 6600000, 700000 6600003, 700003 6600003, 700003 6600000, 700000 6600000)))' % settings.SRID
        self.city = CityFactory(geom=polygon)
        self.district = DistrictFactory(geom=polygon)

        self.poi = POIFactory.create(published=True)

        self.attachment = AttachmentFactory.create(obj=self.poi,
                                                   attachment_file=get_dummy_uploaded_image())

        self.touristic_content = tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True)
        tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=False)  # not published
        tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True).delete()  # deleted
        tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(701000 6601000)' % settings.SRID, published=True)  # too far
        self.touristic_event = tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(700002 6600002)' % settings.SRID, published=True)
        tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(700002 6600002)' % settings.SRID, published=False)  # not published
        tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(700002 6600002)' % settings.SRID, published=True).delete()  # deleted
        tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(702000 6602000)' % settings.SRID, published=True)  # too far

        self.pk = self.poi.pk
        url = '/api/pois/%s/' % self.pk
        self.response = self.client.get(url)
        self.result = json.loads(self.response.content)
Exemplo n.º 16
0
class LevelFactory(factory.DjangoModelFactory):
    class Meta:
        model = models.Level

    name = factory.Sequence(lambda n: "level %s" % n)
    description = factory.Sequence(lambda n: "<p>description %s</p>" % n)
    pictogram = get_dummy_uploaded_image('level-%s.png')
Exemplo n.º 17
0
    def test_upload(self):
        path = PathFactory(length=1)
        response = self.client.get(path.get_update_url())

        f = get_dummy_uploaded_image()
        data = {"filetype": FileTypeFactory().pk, "title": "title1", "legend": "legend1", "attachment_file": f}

        response = self.client.post(add_url_for_obj(path), data=data)
        self.assertEquals(response.status_code, 302)

        att = Attachment.objects.attachments_for_object(path).get()
        self.assertEqual(att.title, data["title"])
        self.assertEqual(att.legend, data["legend"])
        self.assertEqual(att.filetype.pk, data["filetype"])

        f.open()
        self.assertEqual(att.attachment_file.readlines(), f.readlines())

        # Check that if title is given, filename is title
        self.assertTrue(att.attachment_file.name, "title1")

        # Check that if no title is give, filename is original name
        data["title"] = ""
        response = self.client.post(add_url_for_obj(path), data=data)
        att = Attachment.objects.attachments_for_object(path)[0]
        self.assertTrue(att.attachment_file.name, "image")
Exemplo n.º 18
0
    def _build_object(self):
        polygon = 'SRID=%s;MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))' % settings.SRID
        self.city = zoning_factories.CityFactory(geom=polygon)
        self.district = zoning_factories.DistrictFactory(geom=polygon)

        self.content = self.factory(geom='SRID=%s;POINT(1 1)' % settings.SRID)

        self.picture = common_factories.AttachmentFactory(obj=self.content,
                                                          attachment_file=get_dummy_uploaded_image())
        self.document = common_factories.AttachmentFactory(obj=self.content,
                                                           attachment_file=get_dummy_uploaded_document())
        self.video = common_factories.AttachmentFactory(obj=self.content, attachment_file='',
                                                        attachment_video='https://www.youtube.com/watch?v=Jm3anSjly0Y')
        self.video_detected = detect_backend(self.video.attachment_video)

        self.theme = common_factories.ThemeFactory()
        self.content.themes.add(self.theme)
        self.source = common_factories.RecordSourceFactory()
        self.content.source.add(self.source)

        path = core_factories.PathFactory(geom='SRID=%s;LINESTRING(0 10, 10 10)' % settings.SRID)
        self.trek = trekking_factories.TrekFactory(no_path=True)
        self.trek.add_path(path)
        self.poi = trekking_factories.POIFactory(no_path=True)
        self.poi.add_path(path, start=0.5, end=0.5)
Exemplo n.º 19
0
 def test_attachments_missing_from_disk(self):
     trek_1 = TrekWithPublishedPOIsFactory.create(published_fr=True)
     attachment = AttachmentFactory(content_object=trek_1, attachment_file=get_dummy_uploaded_image())
     os.remove(attachment.attachment_file.path)
     management.call_command('sync_mobile', 'tmp', url='http://localhost:8000',
                             skip_tiles=True, languages='fr', verbosity=2, stdout=StringIO())
     self.assertFalse(os.path.exists(os.path.join('tmp', 'nolang', 'media', 'trekking_trek')))
Exemplo n.º 20
0
 def test_attachments_missing_from_disk(self):
     trek_1 = TrekWithPublishedPOIsFactory.create(published_fr=True)
     attachment = AttachmentFactory(content_object=trek_1, attachment_file=get_dummy_uploaded_image())
     os.remove(attachment.attachment_file.path)
     management.call_command('sync_mobile', 'tmp', url='http://localhost:8000',
                             skip_tiles=True, languages='fr', verbosity=2, stdout=BytesIO())
     self.assertFalse(os.path.exists(os.path.join('tmp', 'nolang', 'media', 'trekking_trek')))
Exemplo n.º 21
0
 def test_save_delete_cover(self):
     user = self.login()
     page = FlatPage.objects.create(
         title='Title',
         external_url='http://geotrek.fr',
         target='all'
     )
     filetype = FileType.objects.create(type="Photographie")
     Attachment.objects.create(
         content_object=page,
         attachment_file=get_dummy_uploaded_image(),
         author='Someone',
         filetype=filetype,
         creator=user
     )
     data = {
         'title_en': 'Title',
         'external_url_en': 'http://geotrek.fr',
         'target': 'all',
         'cover_image_author': '',
         'cover_image-clear': 'on',
     }
     form = FlatPageForm(data, instance=page, user=user)
     self.assertTrue(form.is_valid())
     form.save()
     self.assertFalse(Attachment.objects.exists())
Exemplo n.º 22
0
class TouristicContentCategoryFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = models.TouristicContentCategory

    label = "Category"
    type1_label = "Type1 label"
    # Keep type2_label with default value
    pictogram = get_dummy_uploaded_image('touristiccontent-category.png')
Exemplo n.º 23
0
class LabelFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = models.Label

    name = "Label"
    pictogram = get_dummy_uploaded_image('label.png')
    advice = "Advice label"
    filter = True
Exemplo n.º 24
0
 def test_attachments_missing_from_disk(self):
     trek_1 = TrekWithPublishedPOIsFactory.create(published_fr=True)
     attachment = AttachmentFactory(content_object=trek_1, attachment_file=get_dummy_uploaded_image())
     os.remove(attachment.attachment_file.path)
     with self.assertRaises(CommandError) as e:
         management.call_command('sync_rando', 'tmp', url='http://localhost:8000',
                                 skip_tiles=True, languages='fr', verbosity=2, stdout=BytesIO())
     self.assertEqual(e.exception.message, 'Some errors raised during synchronization.')
     self.assertFalse(os.path.exists(os.path.join('tmp', 'mobile', 'nolang', 'media', 'trekking_trek')))
Exemplo n.º 25
0
    def setUp(self):
        self.user = SuperUserFactory.create(password='******')
        self.content = POIFactory.create(geom='SRID=%s;POINT(1 1)' %
                                         settings.SRID)

        self.picture = AttachmentFactory(
            content_object=self.content,
            title='img1',
            attachment_file=get_dummy_uploaded_image())
        self.trek = TrekFactory.create(
            geom='SRID=%s;LINESTRING(0 0, 1 0, 2 0)' % settings.SRID)
        self.picture_2 = AttachmentFactory(
            content_object=self.trek,
            title='img2',
            attachment_file=get_dummy_uploaded_image())
        if os.path.exists(settings.MEDIA_ROOT):
            shutil.rmtree(settings.MEDIA_ROOT)
        os.makedirs(settings.MEDIA_ROOT)
Exemplo n.º 26
0
 def test_reports_with_file(self):
     self.data['file'] = get_dummy_uploaded_file()
     self.data['csv'] = get_dummy_uploaded_image_svg()
     self.data['image'] = get_dummy_uploaded_image()
     self.post_report_data(self.data)
     self.assertTrue(
         feedback_models.Report.objects.filter(
             email='*****@*****.**').exists())
     report = feedback_models.Report.objects.get()
     self.assertEqual(report.attachments.count(), 3)
Exemplo n.º 27
0
    def setUpClass(cls):
        super(SyncMobileTreksTest, cls).setUpClass()
        cls.portal_a = TargetPortalFactory()
        cls.portal_b = TargetPortalFactory()

        cls.trek_1 = TrekWithPublishedPOIsFactory.create()
        cls.trek_2 = TrekWithPublishedPOIsFactory.create(portals=(cls.portal_a,))
        cls.trek_3 = TrekWithPublishedPOIsFactory.create(portals=(cls.portal_b,))

        cls.attachment_1 = AttachmentFactory.create(content_object=cls.trek_1,
                                                    attachment_file=get_dummy_uploaded_image())
        cls.poi_1 = POI.objects.first()
        cls.attachment_poi_image_1 = AttachmentFactory.create(content_object=cls.poi_1,
                                                              attachment_file=get_dummy_uploaded_image())
        cls.attachment_poi_image_2 = AttachmentFactory.create(content_object=cls.poi_1,
                                                              attachment_file=get_dummy_uploaded_image())
        cls.attachment_poi_file = AttachmentFactory.create(content_object=cls.poi_1,
                                                           attachment_file=get_dummy_uploaded_file())
        translation.deactivate()
Exemplo n.º 28
0
    def setUp(self):
        self.source_a = RecordSourceFactory()
        self.source_b = RecordSourceFactory()

        self.portal_a = TargetPortalFactory()
        self.portal_b = TargetPortalFactory()
        information_desks = InformationDeskFactory.create()
        self.trek_1 = TrekWithPublishedPOIsFactory.create(sources=(self.source_a, ),
                                                          portals=(self.portal_b,),
                                                          published=True)
        self.trek_1.information_desks.add(information_desks)
        self.attachment_1 = AttachmentFactory.create(content_object=self.trek_1,
                                                     attachment_file=get_dummy_uploaded_image())
        self.trek_2 = TrekFactory.create(sources=(self.source_b,),
                                         published=True)
        self.trek_3 = TrekFactory.create(portals=(self.portal_b,
                                                  self.portal_a),
                                         published=True)
        self.trek_4 = TrekFactory.create(portals=(self.portal_a,),
                                         published=True)

        self.poi_1 = trek_models.POI.objects.first()
        self.attachment_poi_image_1 = AttachmentFactory.create(content_object=self.poi_1,
                                                               attachment_file=get_dummy_uploaded_image())
        self.attachment_poi_image_2 = AttachmentFactory.create(content_object=self.poi_1,
                                                               attachment_file=get_dummy_uploaded_image())
        self.attachment_poi_file = AttachmentFactory.create(content_object=self.poi_1,
                                                            attachment_file=get_dummy_uploaded_file())

        infrastructure = InfrastructureFactory.create(no_path=True, name="INFRA_1")
        infrastructure.add_path(self.trek_1.paths.first(), start=0, end=0)
        signage = SignageFactory.create(no_path=True, name="SIGNA_1")
        signage.add_path(self.trek_1.paths.first(), start=0, end=0)
        SensitiveAreaFactory.create(published=True)
        self.touristic_content = TouristicContentFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True)
        self.touristic_event = TouristicEventFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True)
        self.attachment_touristic_content = AttachmentFactory.create(content_object=self.touristic_content,
                                                                     attachment_file=get_dummy_uploaded_image())
        self.attachment_touristic_event = AttachmentFactory.create(content_object=self.touristic_event,
                                                                   attachment_file=get_dummy_uploaded_image())
Exemplo n.º 29
0
    def setUpClass(cls):
        super(SyncRandoTestCase, cls).setUpClass()
        cls.source = RecordSourceFactory()
        cls.portal = TargetPortalFactory()

        cls.information_desks = InformationDeskFactory.create()

        cls.touristic_content = TouristicContentFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True)
        cls.touristic_event = TouristicEventFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True)
        cls.attachment_touristic_content = AttachmentFactory.create(content_object=cls.touristic_content,
                                                                    attachment_file=get_dummy_uploaded_image())
        cls.attachment_touristic_event = AttachmentFactory.create(content_object=cls.touristic_event,
                                                                  attachment_file=get_dummy_uploaded_image())

        AttachmentFactory.create(content_object=cls.touristic_content,
                                 attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=cls.touristic_event,
                                 attachment_file=get_dummy_uploaded_image())
Exemplo n.º 30
0
    def test_picture(self):
        trek = TrekFactory.create()
        AttachmentFactory.create(obj=trek)
        self.assertEqual(len(trek.attachments), 1)
        self.assertEqual(trek.thumbnail, None)
        self.assertEqual(trek.pictures, [])

        AttachmentFactory.create(obj=trek, attachment_file=get_dummy_uploaded_image())
        self.assertEqual(len(trek.attachments), 2)
        self.assertEqual(len(trek.pictures), 1)
        self.assertNotEqual(trek.thumbnail, None)
Exemplo n.º 31
0
    def test_picture(self):
        trek = TrekFactory.create()
        AttachmentFactory.create(obj=trek)
        self.assertEqual(len(trek.attachments), 1)
        self.assertEqual(trek.thumbnail, None)
        self.assertEqual(trek.pictures, [])

        AttachmentFactory.create(obj=trek, attachment_file=get_dummy_uploaded_image())
        self.assertEqual(len(trek.attachments), 2)
        self.assertEqual(len(trek.pictures), 1)
        self.assertNotEqual(trek.thumbnail, None)
Exemplo n.º 32
0
 def setUpTestData(cls):
     cls.client = Client()
     cls.nb_treks = 15
     cls.nb_pois = 55
     cls.theme = common_factory.ThemeFactory.create()
     cls.network = trek_factory.TrekNetworkFactory.create()
     cls.label = trek_factory.LabelTrekFactory()
     cls.treks = trek_factory.TrekWithPOIsFactory.create_batch(cls.nb_treks)
     cls.treks[0].themes.add(cls.theme)
     cls.treks[0].networks.add(cls.network)
     cls.treks[0].labels.add(cls.label)
     trek_models.TrekRelationship(trek_a=cls.treks[0],
                                  trek_b=cls.treks[1]).save()
     information_desk_type = tourism_factory.InformationDeskTypeFactory()
     info_desk = tourism_factory.InformationDeskFactory(
         type=information_desk_type)
     cls.treks[0].information_desks.add(info_desk)
     cls.attachment_1 = common_factory.AttachmentFactory.create(
         content_object=cls.treks[0],
         attachment_file=get_dummy_uploaded_image())
     cls.treks[3].parking_location = None
     cls.treks[3].points_reference = MultiPoint(
         [Point(0, 0), Point(1, 1)], srid=settings.SRID)
     cls.treks[3].save()
     cls.path = core_factory.PathFactory.create()
     cls.parent = trek_factory.TrekFactory.create(published=True,
                                                  name='Parent')
     cls.child1 = trek_factory.TrekFactory.create(published=False,
                                                  name='Child 1')
     cls.child2 = trek_factory.TrekFactory.create(published=True,
                                                  name='Child 2')
     trek_models.TrekRelationship(trek_a=cls.parent,
                                  trek_b=cls.treks[0]).save()
     trek_models.OrderedTrekChild(parent=cls.parent,
                                  child=cls.child1,
                                  order=2).save()
     trek_models.OrderedTrekChild(parent=cls.parent,
                                  child=cls.child2,
                                  order=1).save()
     trek_models.OrderedTrekChild(parent=cls.treks[0],
                                  child=cls.child2,
                                  order=3).save()
     cls.content = tourism_factory.TouristicContentFactory.create(
         published=True)
     cls.city = zoning_factory.CityFactory(code=31000)
     cls.district = zoning_factory.DistrictFactory(id=420)
     cls.accessibility = trek_factory.AccessibilityFactory(id=4)
     cls.route = trek_factory.RouteFactory()
     cls.theme = common_factory.ThemeFactory(id=15)
     cls.portal = common_factory.TargetPortalFactory(id=16)
     cls.structure = authent_factory.StructureFactory(id=8)
     cls.nb_treks += 2  # add parent and 1 child published
Exemplo n.º 33
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'])
Exemplo n.º 34
0
 def setUp(self):
     super().setUp()
     self.information_desks = InformationDeskFactory.create()
     self.trek = TrekWithPublishedPOIsFactory.create(published=True)
     if settings.TREKKING_TOPOLOGY_ENABLED:
         InfrastructureFactory.create(paths=[(self.trek.paths.first(), 0, 0)
                                             ],
                                      name="INFRA_1")
         SignageFactory.create(paths=[(self.trek.paths.first(), 0, 0)],
                               name="SIGNA_1")
     else:
         InfrastructureFactory.create(
             geom='SRID=2154;POINT(700000 6600000)', name="INFRA_1")
         SignageFactory.create(geom='SRID=2154;POINT(700000 6600000)',
                               name="SIGNA_1")
     area = SensitiveAreaFactory.create(published=True)
     area.species.practices.add(
         SportPracticeFactory.create(name='Terrestre'))
     area.save()
     self.touristic_content = TouristicContentFactory(
         geom='SRID=%s;POINT(700001 6600001)' % settings.SRID,
         published=True)
     self.touristic_event = TouristicEventFactory(
         geom='SRID=%s;POINT(700001 6600001)' % settings.SRID,
         published=True)
     self.attachment_touristic_content = AttachmentFactory.create(
         content_object=self.touristic_content,
         attachment_file=get_dummy_uploaded_image())
     self.attachment_touristic_event = AttachmentFactory.create(
         content_object=self.touristic_event,
         attachment_file=get_dummy_uploaded_image())
     self.touristic_content_without_attachment = TouristicContentFactory(
         geom='SRID=%s;POINT(700002 6600002)' % settings.SRID,
         published=True)
     self.touristic_event_without_attachment = TouristicEventFactory(
         geom='SRID=%s;POINT(700002 6600002)' % settings.SRID,
         published=True)
Exemplo n.º 35
0
class InformationDeskFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = models.InformationDesk

    name = "Information desk"
    type = factory.SubFactory(InformationDeskTypeFactory)
    description = "<p>Description</p>"
    phone = "01 02 03 04 05"
    email = "*****@*****.**"
    website = "https://makina-corpus.com"
    photo = get_dummy_uploaded_image('photo')
    street = "42 Baker street"
    postal_code = '28300'
    municipality = "Bailleau L'évêque"
    geom = Point(3.14, 42)
Exemplo n.º 36
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'])
Exemplo n.º 37
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.º 38
0
 def test_document_export_with_attachment(self, mock_requests):
     obj = self.modelfactory.create()
     attachment = AttachmentFactory.create(content_object=obj,
                                           attachment_file=get_dummy_uploaded_image(),
                                           title='mapimage')
     obj.attachment = attachment
     obj.save()
     self.login()
     mock_requests.get.return_value.status_code = 200
     mock_requests.get.return_value.content = '<p id="properties">Mock</p>'
     response = self.client.get(obj.get_document_url())
     self.assertEqual(response.status_code, 200)
     element_in_dir = os.listdir(os.path.join(settings.MEDIA_ROOT, 'maps'))
     first_path = os.path.join(settings.MEDIA_ROOT, 'maps', element_in_dir[0])
     second_path = os.path.join(settings.MEDIA_ROOT, attachment.attachment_file.name)
     self.assertTrue(filecmp.cmp(first_path, second_path))
Exemplo n.º 39
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'])
Exemplo n.º 40
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.º 41
0
 def test_document_export_with_attachment(self, mock_requests):
     obj = self.modelfactory.create()
     attachment = AttachmentFactory.create(content_object=obj,
                                           attachment_file=get_dummy_uploaded_image(),
                                           title='mapimage')
     obj.attachment = attachment
     obj.save()
     self.login()
     mock_requests.get.return_value.status_code = 200
     mock_requests.get.return_value.content = '<p id="properties">Mock</p>'
     response = self.client.get(obj.get_document_url())
     self.assertEqual(response.status_code, 200)
     element_in_dir = os.listdir(os.path.join(settings.MEDIA_ROOT, 'maps'))
     first_path = os.path.join(settings.MEDIA_ROOT, 'maps', element_in_dir[0])
     second_path = os.path.join(settings.MEDIA_ROOT, attachment.attachment_file.name)
     self.assertTrue(filecmp.cmp(first_path, second_path))
Exemplo n.º 42
0
    def _build_object(self):
        polygon = 'SRID=%s;MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))' % settings.SRID
        self.city = zoning_factories.CityFactory(geom=polygon)
        self.district = zoning_factories.DistrictFactory(geom=polygon)

        self.content = self.factory(geom='SRID=%s;POINT(1 1)' % settings.SRID)

        self.attachment = common_factories.AttachmentFactory(obj=self.content,
                                                             attachment_file=get_dummy_uploaded_image())
        self.theme = common_factories.ThemeFactory()
        self.content.themes.add(self.theme)

        path = core_factories.PathFactory(geom='SRID=%s;LINESTRING(0 10, 10 10)' % settings.SRID)
        self.trek = trekking_factories.TrekFactory(no_path=True)
        self.trek.add_path(path)
        self.poi = trekking_factories.POIFactory(no_path=True)
        self.poi.add_path(path, start=0.5, end=0.5)
Exemplo n.º 43
0
 def test_save_with_cover(self):
     user = self.login()
     data = {
         'title_en': 'Title',
         'external_url_en': 'http://geotrek.fr',
         'target': 'all',
         'cover_image_author': 'Someone',
     }
     file_data = {
         'cover_image': get_dummy_uploaded_image(),
     }
     form = FlatPageForm(data, file_data, user=user)
     self.assertTrue(form.is_valid())
     form.save()
     page = FlatPage.objects.get()
     attachment = Attachment.objects.get()
     self.assertEqual(attachment.content_object, page)
     self.assertEqual(attachment.author, 'Someone')
Exemplo n.º 44
0
    def setUp(self):
        self.login()

        polygon = 'SRID=%s;MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))' % settings.SRID
        self.city = CityFactory(geom=polygon)
        self.district = DistrictFactory(geom=polygon)

        self.trek = TrekFactory.create(
            points_reference=MultiPoint([Point(0, 0), Point(1, 1)], srid=settings.SRID),
            parking_location=Point(0, 0, srid=settings.SRID)
        )

        self.attachment = AttachmentFactory.create(obj=self.trek,
                                                   attachment_file=get_dummy_uploaded_image())

        self.information_desk = tourism_factories.InformationDeskFactory.create()
        self.trek.information_desks.add(self.information_desk)

        self.usage = UsageFactory.create()
        self.trek.usages.add(self.usage)

        self.theme = ThemeFactory.create()
        self.trek.themes.add(self.theme)

        self.network = TrekNetworkFactory.create()
        self.trek.networks.add(self.network)

        self.weblink = WebLinkFactory.create()
        self.trek.web_links.add(self.weblink)

        self.trek_b = TrekFactory.create()
        TrekRelationshipFactory.create(has_common_departure=True,
                                       has_common_edge=False,
                                       is_circuit_step=True,
                                       trek_a=self.trek,
                                       trek_b=self.trek_b)

        self.touristic_content = tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID)
        self.touristic_event = tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID)

        self.pk = self.trek.pk
        url = '/api/treks/%s/' % self.pk
        self.response = self.client.get(url)
        self.result = json.loads(self.response.content)
Exemplo n.º 45
0
    def setUpClass(cls):
        super(SyncRandoTestCase, cls).setUpClass()
        cls.trek = TrekWithPublishedPOIsFactory.create(published=True)
        cls.information_desks = InformationDeskFactory.create()
        cls.trek.information_desks.add(cls.information_desks)
        cls.attachment = AttachmentFactory.create(
            content_object=cls.trek,
            attachment_file=get_dummy_uploaded_image())

        cls.source_a = RecordSourceFactory()
        cls.source_b = RecordSourceFactory()

        cls.portal_a = TargetPortalFactory()
        cls.portal_b = TargetPortalFactory()
        cls.trek_fr = TrekFactory.create(published_fr=True,
                                         sources=(cls.source_b, ))
        cls.trek_sb = TrekFactory.create(sources=(cls.source_b, ),
                                         published=True)

        cls.trek_sb_pa = TrekFactory.create(sources=(cls.source_b, ),
                                            portals=(cls.portal_a, ),
                                            published=True)

        cls.touristic_content = TouristicContentFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID,
            published=True)
        cls.touristic_event = TouristicEventFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID,
            published=True)
        cls.attachment_touristic_content = AttachmentFactory.create(
            content_object=cls.touristic_content,
            attachment_file=get_dummy_uploaded_image())
        cls.attachment_touristic_event = AttachmentFactory.create(
            content_object=cls.touristic_event,
            attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=cls.touristic_content,
                                 attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=cls.touristic_event,
                                 attachment_file=get_dummy_uploaded_image())
        cls.poi = trek_models.POI.objects.first()
        cls.attachment_poi_image = AttachmentFactory.create(
            content_object=cls.poi, attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=cls.poi,
                                 attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=cls.poi,
                                 attachment_file=get_dummy_uploaded_file())
Exemplo n.º 46
0
    def setUp(self):
        self.login()

        polygon = 'SRID=%s;MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))' % settings.SRID
        self.city = CityFactory(geom=polygon)
        self.district = DistrictFactory(geom=polygon)

        self.poi = POIFactory.create(geom=Point(0, 0, srid=settings.SRID))

        self.attachment = AttachmentFactory.create(obj=self.poi,
                                                   attachment_file=get_dummy_uploaded_image())

        self.touristic_content = tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID)
        self.touristic_event = tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID)

        self.pk = self.poi.pk
        url = '/api/pois/%s/' % self.pk
        self.response = self.client.get(url)
        self.result = json.loads(self.response.content)
Exemplo n.º 47
0
 def test_picture_is_taken_among_attachments(self):
     self.add_attachment(attachment=get_dummy_uploaded_image())
     self.assertEqual(len(self.trek.attachments), 2)
     self.assertEqual(len(self.trek.pictures), 1)
     self.assertNotEqual(self.trek.thumbnail, None)
Exemplo n.º 48
0
    def setUp(self):
        self.login()

        polygon = 'SRID=%s;MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))' % settings.SRID
        self.city = CityFactory(geom=polygon)
        self.district = DistrictFactory(geom=polygon)

        self.parent = TrekFactory.create(published=True)

        self.trek = TrekFactory.create(
            parent=self.parent,
            no_path=True,
            points_reference=MultiPoint([Point(0, 0), Point(1, 1)], srid=settings.SRID),
            parking_location=Point(0, 0, srid=settings.SRID)
        )
        path1 = PathFactory.create(geom='SRID=%s;LINESTRING(0 0, 1 0)' % settings.SRID)
        self.trek.add_path(path1)

        self.attachment = AttachmentFactory.create(obj=self.trek,
                                                   attachment_file=get_dummy_uploaded_image())

        self.information_desk = tourism_factories.InformationDeskFactory.create()
        self.trek.information_desks.add(self.information_desk)

        self.theme = ThemeFactory.create()
        self.trek.themes.add(self.theme)

        self.accessibility = AccessibilityFactory.create()
        self.trek.accessibilities.add(self.accessibility)

        self.network = TrekNetworkFactory.create()
        self.trek.networks.add(self.network)

        self.weblink = WebLinkFactory.create()
        self.trek.web_links.add(self.weblink)

        self.source = RecordSourceFactory.create()
        self.trek.source.add(self.source)

        self.trek_b = TrekFactory.create(no_path=True,
                                         geom='SRID=%s;POINT(2 2)' % settings.SRID,
                                         published=True)
        path2 = PathFactory.create(geom='SRID=%s;LINESTRING(0 1, 1 1)' % settings.SRID)
        self.trek_b.add_path(path2)
        TrekRelationshipFactory.create(has_common_departure=True,
                                       has_common_edge=False,
                                       is_circuit_step=True,
                                       trek_a=self.trek,
                                       trek_b=self.trek_b)

        self.touristic_content = tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID, published=True)
        tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID, published=False)  # not published
        tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID, published=True).delete()  # deleted
        tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1000 1000)' % settings.SRID, published=True)  # too far
        self.touristic_event = tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID, published=True)
        tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID, published=False)  # not published
        tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID, published=True).delete()  # deleted
        tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2000 2000)' % settings.SRID, published=True)  # too far
        trek2 = TrekFactory(no_path=True, published=False)  # not published
        trek2.add_path(path2)
        trek3 = TrekFactory(no_path=True, published=True)  # deleted
        trek3.add_path(path2)
        trek3.delete()
        trek4 = TrekFactory(no_path=True, published=True)  # too far
        trek4.add_path(PathFactory.create(geom='SRID=%s;LINESTRING(0 2000, 1 2000)' % settings.SRID))

        self.child1 = TrekFactory.create(published=False, parent=self.trek)
        self.child2 = TrekFactory.create(published=True, parent=self.trek)

        self.pk = self.trek.pk
        url = '/api/treks/%s/' % self.pk
        self.response = self.client.get(url)
        self.result = json.loads(self.response.content)
Exemplo n.º 49
0
def dummy_filefield_as_sequence(toformat_name):
    """Simple helper method to fill a models.FileField"""
    return factory.Sequence(lambda n: get_dummy_uploaded_image(toformat_name % n))