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()
def get_dummy_data_trad(cls): return dict(id=1, difficulty=u"difficulty_descr_default", difficulty_en=u"difficulty_descr_en", difficulty_fr=u"difficulty_descr_fr", difficulty_it=u"difficulty_descr_it", pictogram=get_dummy_uploaded_file())
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()
def get_dummy_data_trad(cls): return dict( id=1, difficulty=u"difficulty_descr_default", difficulty_en=u"difficulty_descr_en", difficulty_fr=u"difficulty_descr_fr", difficulty_it=u"difficulty_descr_it", pictogram=get_dummy_uploaded_file() )
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)
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())
class AttachmentFactory(factory.django.DjangoModelFactory): """ Create an attachment. You must provide an 'obj' keywords, the object (saved in db) to which the attachment will be bound. """ class Meta: model = Attachment attachment_file = get_dummy_uploaded_file() filetype = factory.SubFactory(FileTypeFactory) creator = factory.SubFactory(UserFactory) title = factory.Sequence("Title {0}".format) legend = factory.Sequence("Legend {0}".format)
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())
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()
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())
class AttachmentFactory(factory.DjangoModelFactory): """ Create an attachment. You must provide an 'obj' keywords, the object (saved in db) to which the attachment will be bound. """ class Meta: model = Attachment attachment_file = get_dummy_uploaded_file() filetype = factory.SubFactory(FileTypeFactory) creator = factory.SubFactory(UserFactory) title = factory.Sequence(u"Title {0}".format) legend = factory.Sequence(u"Legend {0}".format) # date_insert, date_update @classmethod def _prepare(cls, create, obj=None, **kwargs): kwargs['content_type'] = ContentType.objects.get_for_model(obj) kwargs['object_id'] = obj.pk return super(AttachmentFactory, cls)._prepare(create, **kwargs)
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,))
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())
def setUpTestData(cls): cls.client = Client() cls.nb_treks = 15 cls.theme = common_factory.ThemeFactory.create() cls.network = trek_factory.TrekNetworkFactory.create() cls.label = common_factory.LabelFactory(id=23) 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() cls.info_desk = tourism_factory.InformationDeskFactory( type=information_desk_type) cls.treks[0].information_desks.add(cls.info_desk) common_factory.AttachmentFactory.create( content_object=cls.treks[0], attachment_file=get_dummy_uploaded_image()) common_factory.AttachmentFactory.create( content_object=cls.treks[0], attachment_file=get_dummy_uploaded_file()) common_factory.AttachmentFactory.create( content_object=cls.treks[0], attachment_file=get_dummy_uploaded_document()) common_factory.AttachmentFactory( content_object=cls.treks[0], attachment_file='', attachment_video= 'https://www.youtube.com/embed/Jm3anSjly0Y?wmode=opaque') common_factory.AttachmentFactory( content_object=cls.treks[0], attachment_file='', attachment_video='', attachment_link='https://geotrek.fr/assets/img/logo.svg') common_factory.AttachmentFactory(content_object=cls.treks[0], attachment_file='', attachment_video='', attachment_link='') 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(id=680) 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 cls.poi_type = trek_factory.POITypeFactory() cls.poi = trek_factory.POIFactory() cls.source = common_factory.RecordSourceFactory() cls.reservation_system = common_factory.ReservationSystemFactory() cls.site = outdoor_factory.SiteFactory()