示例#1
0
    def setUp(self):
        self.contents = []
        self.events = []
        self.portals = []

        self.portal_a = TargetPortalFactory()
        self.portal_b = TargetPortalFactory()

        self.source_a = RecordSourceFactory()
        self.source_b = RecordSourceFactory()

        self.content_1 = TouristicContentFactory.create(
            portals=(self.portal_a, self.portal_b),
            sources=(self.source_a, self.source_b))

        self.content_2 = TouristicContentFactory.create(
            portals=(self.portal_a, ), sources=(self.source_a, self.source_b))

        self.event_1 = TouristicEventFactory.create(portals=(self.portal_a,
                                                             self.portal_b),
                                                    sources=(self.source_b, ))

        self.event_2 = TouristicEventFactory.create(portals=(self.portal_b, ),
                                                    sources=(self.source_a,
                                                             self.source_b))
    def setUp(self):
        TouristicEventFactory.create_batch(30)
        TouristicEventFactory.create(name='toto')

        self.login()
        self.user.is_superuser = True
        self.user.save()
        self.logout()
示例#3
0
 def setUp(self):
     profile = UserProfileFactory.create(user__username='******',
                                         user__password='******')
     user = profile.user
     user.groups.add(Group.objects.get(name=u"Référents communication"))
     self.client.login(username=user.username, password='******')
     self.event1 = TouristicEventFactory.create()
     structure = StructureFactory.create()
     self.event2 = TouristicEventFactory.create(structure=structure)
示例#4
0
 def setUp(self):
     profile = UserProfileFactory.create(user__username='******',
                                         user__password='******')
     user = profile.user
     user.groups.add(Group.objects.get(name=u"Référents communication"))
     self.client.login(username=user.username, password='******')
     self.event1 = TouristicEventFactory.create()
     structure = StructureFactory.create()
     self.event2 = TouristicEventFactory.create(structure=structure)
示例#5
0
 def test_touristic_events_with_enddate_filter(self):
     TouristicEventFactory.create_batch(5, published=True)
     TouristicEventFactory.create_batch(5,
                                        end_date=datetime.strptime(
                                            '2020-05-10', '%Y-%m-%d'),
                                        published=True)
     response = self.client.get('/api/en/touristicevents.geojson',
                                data={'ends_after': '2020-01-01'})
     geojson = json.loads(response.content)
     self.assertEqual(len(geojson['features']), 5)
 def test_every_field_column_none(self):
     self.login_as_superuser()
     TouristicEventFactory.create()
     request = RequestFactory().get('/fake-path')
     request.user = self.superuser
     request.session = {}
     view = TestList.as_view()
     response = view(request)
     html = response.render()
     self.assertEqual(response.status_code, 200)
     self.assertTrue(b'Description' in html.content)
 def test_field_no_field_but_verbose_name_field(self):
     object_event = TouristicEventFactory.create()
     setattr(object_event, 'do_not_exist_verbose_name', "test")
     template = Template('{% load mapentity_tags %}'
                         '{{ object|verbose:"do_not_exist" }}').render(
                             Context({'object': object_event}))
     self.assertEqual(template, "test")
 def test_time_since_now(self):
     date = make_aware(datetime.now(), utc)
     object_event = TouristicEventFactory.create(begin_date=date)
     out = Template('{% load mapentity_tags %}'
                    '{{ object.begin_date|timesince }}').render(
                        Context({'object': object_event}))
     self.assertIn('just a few seconds ago', out)
示例#9
0
 def test_public_document_pdf(self, mocked):
     content = TouristicEventFactory.create(published=True)
     url = '/api/en/touristicevents/{pk}/slug.pdf'.format(pk=content.pk)
     mocked.return_value.status_code = 200
     mocked.return_value.content = PNG_BLACK_PIXEL
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200)
示例#10
0
 def test_field_verbose_name_field_does_not_exist(self):
     object_event = TouristicEventFactory.create()
     with self.assertRaisesRegex(FieldDoesNotExist, "TouristicEvent has no field named 'do_not_exist'"):
         Template(
             '{% load mapentity_tags %}'
             '{{ object|verbose:"do_not_exist" }}'
         ).render(Context({'object': object_event}))
 def test_time_since_year(self):
     date = make_aware(datetime.now() - timedelta(days=366), utc)
     object_event = TouristicEventFactory.create(begin_date=date)
     out = Template('{% load mapentity_tags %}'
                    '{{ object.begin_date|timesince }}').render(
                        Context({'object': object_event}))
     self.assertEqual('1 year ago', out)
示例#12
0
 def setUp(self):
     User = get_user_model()
     self.object = TouristicEventFactory.create()
     user = User.objects.create_user('aah', '*****@*****.**', 'booh')
     user.is_superuser = True
     user.save()
     success = self.client.login(username=user.username, password='******')
     self.assertTrue(success)
示例#13
0
 def test_delete_view_logs_deletion(self):
     obj = TouristicEventFactory.create()
     self.client.post('/touristicevent/delete/{0}/'.format(obj.pk))
     self.assertEqual(LogEntry.objects.count(), 1)
     entry = LogEntry.objects.get()
     self.assertEqual(entry.object_id, str(obj.pk))
     self.assertEqual(entry.action_flag, DELETION)
     self.assertEqual(entry.user, self.user)
 def test_latlngbound_object(self):
     object_event = TouristicEventFactory.create()
     out = Template('{% load mapentity_tags %}'
                    '{{ object|latlngbounds }}').render(
                        Context({'object': object_event}))
     self.assertEqual(
         '[[-5.983856309208756, -1.3630812101178977], '
         '[-5.983856309208756, -1.3630812101178977]]', out)
示例#15
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()
示例#16
0
 def test_can_specify_field_to_be_used(self):
     obj = TouristicEventFactory.create(name='blah')
     out = Template(
         '{% load mapentity_tags %}'
         '{% valuelist items field="name" %}'
     ).render(Context({
         'items': [obj]
     }))
     self.assertIn("""title="blah">blah</a></li>""", out.strip())
示例#17
0
    def setUp(self):
        User = get_user_model()
        self.user = User.objects.create_user('howard', '*****@*****.**', 'booh')

        def user_perms(p):
            return {'paperclip.add_attachment': False}.get(p, True)

        self.user.has_perm = mock.MagicMock(side_effect=user_perms)
        self.object = TouristicEventFactory.create()
        call_command('update_geotrek_permissions', verbosity=0)
示例#18
0
 def test_latlngbound_object(self):
     object_event = TouristicEventFactory.create()
     out = Template(
         '{% load mapentity_tags %}'
         '{{ object|latlngbounds }}'
     ).render(Context({'object': object_event}))
     json_out = json.loads(out)
     self.assertAlmostEqual(json_out[0][0], -5.9838563092087576)
     self.assertAlmostEqual(json_out[0][1], -1.363081210117898)
     self.assertAlmostEqual(json_out[1][0], -5.9838563092087576)
     self.assertAlmostEqual(json_out[1][1], -1.363081210117898)
示例#19
0
    def test_can_delete_actions(self):
        sample_object = TouristicEventFactory.create()
        delete_url = sample_object.get_delete_url()
        form = DummyForm(instance=sample_object)
        self.assertTrue(form.can_delete)
        self.assertTrue(('<a class="btn btn-danger delete" href="%s">' %
                         delete_url) in form.helper.layout[1][0].html)

        form = DummyForm(instance=sample_object, can_delete=False)
        self.assertFalse(form.can_delete)
        self.assertTrue('<a class="btn disabled delete" href="#">' in
                        form.helper.layout[1][0].html)
示例#20
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())
示例#21
0
 def test_auto_login_happens_by_remote_addr(self):
     obj = TouristicEventFactory.create(published=False)
     middleware.AUTOLOGIN_IPS = ['1.2.3.4']
     attachment = AttachmentFactory.create(content_object=obj)
     response = self.client.get("/media/%s" % attachment.attachment_file,
                                REMOTE_ADDR='1.2.3.5')
     self.assertEqual(response.status_code, 403)
     with mock.patch('django.contrib.auth.models._user_has_perm',
                     return_value=True):
         response = self.client.get("/media/%s" %
                                    attachment.attachment_file,
                                    REMOTE_ADDR='1.2.3.4')
     self.assertEqual(response.status_code, 200)
示例#22
0
 def setUp(self):
     app_settings['SENDFILE_HTTP_HEADER'] = 'X-Accel-Redirect'
     self.obj = TouristicEventFactory.create(published=False)
     """
     if os.path.exists(settings.MEDIA_ROOT):
         self.tearDown()
     os.makedirs(os.path.join(settings.MEDIA_ROOT, 'paperclip/test_app_dummymodel/{}'.format(self.obj.pk)))
     self.file = os.path.join(settings.MEDIA_ROOT, 'paperclip/test_app_dummymodel/{}/file.pdf'.format(self.obj.pk))
     self.url = '/media/paperclip/test_app_dummymodel/{}/file.pdf'.format(self.obj.pk)
     open(self.file, 'wb').write(b'*' * 300)
     """
     self.attachment = AttachmentFactory.create(content_object=self.obj)
     self.url = "/media/%s" % self.attachment.attachment_file
     call_command('update_geotrek_permissions', verbosity=0)
示例#23
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)
示例#24
0
 def test_update_view_logs_change(self):
     obj = TouristicEventFactory.create()
     self.client.post('/touristicevent/edit/{0}/'.format(obj.pk),
                      data={
                          'structure': Structure.objects.first().pk,
                          'name_en': 'test',
                          'geom':
                          '{"type": "Point", "coordinates": [0, 0]}',
                          'model': 'touristicevent',
                      })
     self.assertEqual(LogEntry.objects.count(), 1)
     entry = LogEntry.objects.get()
     self.assertEqual(entry.get_edited_object(), obj)
     self.assertEqual(entry.action_flag, CHANGE)
     self.assertEqual(entry.user, self.user)
示例#25
0
    def test_overriden_document(self):
        event = TouristicEventFactory.create(published=True)

        with open(event.get_map_image_path(), 'w') as f:
            f.write('***' * 1000)

        url = '/api/en/touristicevents/{pk}/slug.odt'.format(pk=event.pk)
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertTrue(len(response.content) > 1000)

        AttachmentFactory.create(obj=event, title="docprint", attachment_file=get_dummy_uploaded_document(size=100))
        url = '/api/en/touristicevents/{pk}/slug.odt'.format(pk=event.pk)
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertTrue(len(response.content) < 1000)
示例#26
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())
示例#27
0
    def test_overriden_document(self):
        event = TouristicEventFactory.create(published=True)

        with open(event.get_map_image_path(), 'w') as f:
            f.write('***' * 1000)

        url = '/api/en/touristicevents/{pk}/slug.odt'.format(pk=event.pk)
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertTrue(len(response.content) > 1000)

        AttachmentFactory.create(
            obj=event,
            title="docprint",
            attachment_file=get_dummy_uploaded_document(size=100))
        url = '/api/en/touristicevents/{pk}/slug.odt'.format(pk=event.pk)
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertTrue(len(response.content) < 1000)
示例#28
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())
示例#29
0
    def test_touristic_events_with_enddate_filter(self):
        """
        Relative date: 2020-01-01
        5 events with no end date
        5 events with end date after relative date
        7 events with end date before relative date
                 ->  only events with no end or end in after relative date must be included
        """

        TouristicEventFactory.create_batch(5, end_date=None, published=True)
        TouristicEventFactory.create_batch(5, end_date=datetime.strptime('2020-05-10', '%Y-%m-%d'), published=True)
        TouristicEventFactory.create_batch(7, end_date=datetime.strptime('2010-05-10', '%Y-%m-%d'), published=True)
        response = self.client.get('/api/en/touristicevents.geojson', data={'ends_after': '2020-01-01'})
        geojson = json.loads(response.content)

        self.assertEqual(len(geojson['features']), 10)
示例#30
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')))
示例#31
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,))
示例#32
0
 def test_touristic_events_without_enddate_filter(self):
     TouristicEventFactory.create_batch(10, published=True)
     response = self.client.get('/api/en/touristicevents.geojson')
     geojson = json.loads(response.content)
     self.assertEqual(len(geojson['features']), 10)
示例#33
0
 def test_touristic_events_without_enddate_filter(self):
     TouristicEventFactory.create_batch(10, published=True)
     response = self.client.get('/api/en/touristicevents.geojson')
     geojson = json.loads(response.content)
     self.assertEqual(len(geojson['features']), 10)
示例#34
0
 def test_touristic_events_with_enddate_filter(self):
     TouristicEventFactory.create_batch(5, published=True)
     TouristicEventFactory.create_batch(5, end_date=datetime.strptime('2020-05-10', '%Y-%m-%d'), published=True)
     response = self.client.get('/api/en/touristicevents.geojson', data={'ends_after': '2020-01-01'})
     geojson = json.loads(response.content)
     self.assertEqual(len(geojson['features']), 5)
示例#35
0
 def test_public_document_pdf(self, mocked):
     content = TouristicEventFactory.create(published=True)
     url = '/api/en/touristicevents/{pk}/slug.pdf'.format(pk=content.pk)
     mocked.return_value.status_code = 200
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200)
示例#36
0
 def test_not_published_document_pdf(self):
     content = TouristicEventFactory.create(published=False)
     url = '/api/en/touristicevents/{pk}/slug.pdf'.format(pk=content.pk)
     response = self.client.get(url)
     self.assertEqual(response.status_code, 403)
示例#37
0
 def setUp(self):
     # TouristicEvent : end_date = datetime.today()
     TouristicEventFactory.create()
     self.qs = TouristicEvent.objects.all()