Esempio n. 1
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()
Esempio n. 2
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())
Esempio n. 3
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)
Esempio n. 4
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())
Esempio n. 5
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())
Esempio n. 6
0
    def test_sync_portal_source(self, stdout, mock_prepare_event, mock_prepare_content):
        def side_effect_sync_event(lang, event):
            self.assertEqual(event, self.touristic_event_p_s)

        def side_effect_sync_content(lang, content):
            self.assertEqual(content, self.touristic_content_p_s)

        self.touristic_content_p_s = TouristicContentFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, sources=(self.source,),
            portals=(self.portal,), published=True)
        self.touristic_event_p_s = TouristicEventFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, sources=(self.source,),
            portals=(self.portal,), published=True)

        command = FakeSyncCommand(portal=self.portal.name, source=[self.source.name])
        synchro = SyncRando(command)
        with patch('geotrek.tourism.helpers_sync.SyncRando.sync_event', side_effect=side_effect_sync_event):
            with patch('geotrek.tourism.helpers_sync.SyncRando.sync_content', side_effect=side_effect_sync_content):
                synchro.sync('en')
        self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'static', 'tourism',
                                                    'touristicevent.svg')))
        self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'en', 'information_desks.geojson')))
Esempio n. 7
0
    def setUpClass(cls):
        super(SyncRandoTestCase, cls).setUpClass()
        cls.practice_dive = PracticeFactory.create(order=0)
        cls.dive = DiveFactory.create(practice=cls.practice_dive, published=True,
                                      geom='SRID=2154;POINT(700001 6600001)')
        cls.attachment_dive = AttachmentFactory.create(content_object=cls.dive,
                                                       attachment_file=get_dummy_uploaded_image())
        cls.poi_dive = POIFactory.create(name="dive_poi", published=True)
        AttachmentFactory.create(content_object=cls.poi_dive,
                                 attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=cls.poi_dive,
                                 attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=cls.poi_dive,
                                 attachment_file=get_dummy_uploaded_file())
        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.source_a = RecordSourceFactory()
        cls.source_b = RecordSourceFactory()

        cls.portal_a = TargetPortalFactory()
        cls.portal_b = TargetPortalFactory()
        cls.dive_portal_source = DiveFactory.create(practice=cls.practice_dive, published=True,
                                                    geom='SRID=2154;POINT(700002 6600002)',
                                                    portals=(cls.portal_a,), sources=(cls.source_a,))
        cls.dive_other_portal_source = DiveFactory.create(practice=cls.practice_dive, published=True,
                                                          geom='SRID=2154;POINT(700002 6600002)',
                                                          portals=(cls.portal_b,), sources=(cls.source_b,))
Esempio n. 8
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.practice_trek = PracticeTrekFactory.create(order=1)
        self.practice_trek_first = PracticeTrekFactory.create(order=0)
        self.trek_1 = TrekWithPublishedPOIsFactory.create(practice=self.practice_trek, 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(practice=self.practice_trek, portals=(self.portal_a,),
                                         published=True)
        self.trek_5 = TrekFactory.create(practice=self.practice_trek_first, portals=(self.portal_a,),
                                         published=True, name="other")

        self.practice_dive = PracticeDiveFactory.create(order=0)

        self.dive_1 = DiveFactory.create(practice=self.practice_dive, sources=(self.source_a,),
                                         portals=(self.portal_b,),
                                         published=True, geom='SRID=2154;POINT(700001 6600001)')
        self.attachment_dive = AttachmentFactory.create(content_object=self.dive_1,
                                                        attachment_file=get_dummy_uploaded_image())
        self.dive_2 = DiveFactory.create(sources=(self.source_b,),
                                         published=True, geom='SRID=2154;LINESTRING (700000 6600000, 700100 6600100)')
        self.dive_3 = DiveFactory.create(portals=(self.portal_b,
                                                  self.portal_a),
                                         published=True, geom='POLYGON((700000 6600000, 700000 6600100, '
                                                              '700100 6600100, 700100 6600000, 700000 6600000))')
        self.dive_4 = DiveFactory.create(practice=self.practice_dive, portals=(self.portal_a,),
                                         published=True)
        self.poi_1 = trek_models.POI.objects.first()
        self.poi_dive = POIFactory.create(name="dive_poi", published=True)
        self.attachment_poi_image_1 = AttachmentFactory.create(content_object=self.poi_1,
                                                               attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=self.poi_dive,
                                 attachment_file=get_dummy_uploaded_image())
        self.attachment_poi_image_2 = AttachmentFactory.create(content_object=self.poi_1,
                                                               attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=self.poi_dive,
                                 attachment_file=get_dummy_uploaded_file())
        self.attachment_poi_file = AttachmentFactory.create(content_object=self.poi_1,
                                                            attachment_file=get_dummy_uploaded_file())
        if settings.TREKKING_TOPOLOGY_ENABLED:
            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)
        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())