Пример #1
0
 def test_bad_settings(self):
     output = StringIO()
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     with self.assertRaisesRegexp(AttributeError, "'int' object has no attribute 'strip'"):
         management.call_command('sync_rando', 'tmp', url='http://localhost:8000',
                                 skip_tiles=True, languages='fr', verbosity=2, stdout=output)
     self.assertIn("failed (Cannot mix str and non-str arguments)", output.getvalue())
Пример #2
0
    def test_tiles_with_treks(self, mock_tiles, mock_prepare, mock_tileslist):
        output = BytesIO()
        portal_a = TargetPortalFactory()
        portal_b = TargetPortalFactory()
        trek = TrekWithPublishedPOIsFactory.create(published=True)
        trek_not_same_portal = TrekWithPublishedPOIsFactory.create(
            published=True, portals=(portal_a, ))
        management.call_command('sync_mobile',
                                'tmp',
                                url='http://localhost:8000',
                                verbosity=2,
                                stdout=output,
                                portal=portal_b.name)

        zfile_global = zipfile.ZipFile(
            os.path.join('tmp', 'nolang', 'global.zip'))
        for finfo in zfile_global.infolist():
            ifile_global = zfile_global.open(finfo)
            if ifile_global.name.startswith('tiles/'):
                self.assertEqual(ifile_global.readline(), 'I am a png')
        zfile_trek = zipfile.ZipFile(
            os.path.join('tmp', 'nolang', '{}.zip'.format(trek.pk)))
        for finfo in zfile_trek.infolist():
            ifile_trek = zfile_trek.open(finfo)
            if ifile_global.name.startswith('tiles/'):
                self.assertEqual(ifile_trek.readline(), 'I am a png')
        self.assertIn("nolang/global.zip", output.getvalue())
        self.assertIn("nolang/{pk}.zip".format(pk=trek.pk), output.getvalue())

        self.assertFalse(
            os.path.exists(
                os.path.join('tmp', 'nolang',
                             '{}.zip'.format(trek_not_same_portal.pk))))
Пример #3
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()
Пример #4
0
 def test_streaminghttpresponse(self, mocke):
     output = StringIO()
     mocke.return_value = StreamingHttpResponse()
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     management.call_command('sync_mobile', 'tmp', url='http://localhost:8000',
                             skip_tiles=True, skip_pdf=True, verbosity=2, stdout=output)
     self.assertTrue(os.path.exists(os.path.join('tmp', 'en', 'treks.geojson')))
Пример #5
0
 def test_bad_settings(self):
     output = StringIO()
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     with self.assertRaisesRegexp(AttributeError, "'int' object has no attribute 'strip'"):
         management.call_command('sync_mobile', 'tmp', url='http://localhost:8000',
                                 skip_tiles=True, languages='fr', verbosity=2, stdout=output, stderr=StringIO())
         self.assertIn("Exception raised in callable attribute", output.getvalue())
Пример #6
0
 def test_response_view_exception_with_debug(self, mocke):
     output = StringIO()
     mocke.side_effect = ValueError('This is a test')
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     with self.assertRaisesRegexp(ValueError, 'This is a test'):
         management.call_command('sync_rando', 'tmp', url='http://localhost:8000', portal='portal', skip_pdf=True,
                                 skip_tiles=True, languages='fr', verbosity=2, stdout=output)
     self.assertIn("failed (This is a test)", output.getvalue())
Пример #7
0
 def test_streaminghttpresponse(self, mocke):
     output = BytesIO()
     mocke.return_value = StreamingHttpResponse()
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     with mock.patch('geotrek.trekking.models.Trek.prepare_map_image'):
         management.call_command('sync_mobile', 'tmp', url='http://localhost:8000',
                                 skip_tiles=True, verbosity=2, stdout=output)
     self.assertTrue(os.path.exists(os.path.join('tmp', 'en', 'treks.geojson')))
Пример #8
0
 def test_response_500(self, mocke):
     output = StringIO()
     mocke.return_value = HttpResponse(status=500)
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     with self.assertRaisesRegexp(CommandError, 'Some errors raised during synchronization.'):
         management.call_command('sync_mobile', 'tmp', url='http://localhost:8000', portal='portal',
                                 skip_tiles=True, languages='fr', verbosity=2, stdout=output)
     self.assertIn("failed (HTTP 500)", output.getvalue())
Пример #9
0
 def test_bad_settings(self):
     output = BytesIO()
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     with self.assertRaises(AttributeError) as e:
         management.call_command('sync_rando', 'tmp', url='http://localhost:8000',
                                 skip_tiles=True, languages='fr', verbosity=2, stdout=output)
     self.assertEqual(e.exception.message, "'int' object has no attribute 'strip'")
     self.assertIn("Exception raised in callable attribute", output.getvalue())
Пример #10
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()
Пример #11
0
 def test_response_500(self, mocke):
     output = BytesIO()
     mocke.return_value = HttpResponse(status=500)
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     with self.assertRaises(CommandError) as e:
         management.call_command('sync_rando', 'tmp', url='http://localhost:8000',
                                 skip_tiles=True, verbosity=2, stdout=output)
     self.assertEqual(e.exception.message, 'Some errors raised during synchronization.')
     self.assertIn("failed (HTTP 500)", output.getvalue())
Пример #12
0
    def test_response_view_exception(self, mocke):
        output = StringIO()
        mocke.side_effect = Exception('This is a test')
        TrekWithPublishedPOIsFactory.create(published_fr=True)
        with self.assertRaisesRegexp(CommandError, 'Some errors raised during synchronization.'):
            management.call_command('sync_mobile', 'tmp', url='http://localhost:8000', portal='portal',
                                    skip_tiles=True, languages='fr', verbosity=2, stdout=output)

        self.assertIn("failed (This is a test)", output.getvalue())
Пример #13
0
 def test_indent(self):
     indent = 3
     output = StringIO()
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     management.call_command('sync_mobile', 'tmp', url='http://localhost:8000',
                             skip_tiles=True, skip_pdf=True, verbosity=2, indent=indent, stdout=output)
     with open(os.path.join('tmp', 'en', 'treks.geojson')) as f:
         # without indent the json is in one line
         json_file = f.readlines()
         # with indent the json is stocked in more than one line
         self.assertGreater(len(json_file), 1)
         # there are 3 spaces in the second line because the indent is 3
         self.assertEqual(json_file[1][:indent], indent * ' ')
Пример #14
0
 def test_response_500(self, mocke):
     output = BytesIO()
     mocke.return_value = HttpResponse(status=500)
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     with self.assertRaises(CommandError) as e:
         management.call_command('sync_rando',
                                 'tmp',
                                 url='http://localhost:8000',
                                 skip_tiles=True,
                                 verbosity=2,
                                 stdout=output)
     self.assertEqual(e.exception.message,
                      'Some errors raised during synchronization.')
     self.assertIn("failed (HTTP 500)", output.getvalue())
Пример #15
0
 def test_response_500(self, mock_view, mocke_map_image):
     error = StringIO()
     mock_view.return_value.return_value = HttpResponse(status=500)
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     with self.assertRaisesRegex(
             CommandError, 'Some errors raised during synchronization.'):
         management.call_command('sync_rando',
                                 os.path.join('var', 'tmp'),
                                 url='http://localhost:8000',
                                 skip_tiles=True,
                                 verbosity=2,
                                 stdout=StringIO(),
                                 stderr=error)
     self.assertIn("failed (HTTP 500)", error.getvalue())
Пример #16
0
 def test_bad_settings(self):
     output = BytesIO()
     TrekWithPublishedPOIsFactory.create(published_fr=True)
     with self.assertRaises(AttributeError) as e:
         management.call_command('sync_rando',
                                 'tmp',
                                 url='http://localhost:8000',
                                 skip_tiles=True,
                                 languages='fr',
                                 verbosity=2,
                                 stdout=output)
     self.assertEqual(e.exception.message,
                      "'int' object has no attribute 'strip'")
     self.assertIn("Exception raised in callable attribute",
                   output.getvalue())
Пример #17
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')))
Пример #18
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')))
Пример #19
0
 def test_streaminghttpresponse(self, mocke):
     output = StringIO()
     mocke.return_value = StreamingHttpResponse()
     trek = TrekWithPublishedPOIsFactory.create(published_fr=True)
     management.call_command('sync_rando', 'tmp', url='http://localhost:8000', skip_pdf=True,
                             skip_tiles=True, languages='fr', verbosity=2, stdout=output)
     self.assertTrue(os.path.exists(os.path.join('tmp', 'api', 'fr', 'treks', str(trek.pk), 'profile.png')))
Пример #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)
     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')))
Пример #21
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()
Пример #22
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())
Пример #23
0
    def test_tiles_with_treks(self, mock_tiles, mock_prepare, mock_tileslist):
        output = BytesIO()
        portal_a = TargetPortalFactory()
        portal_b = TargetPortalFactory()
        trek = TrekWithPublishedPOIsFactory.create(published=True)
        trek_not_same_portal = TrekWithPublishedPOIsFactory.create(published=True, portals=(portal_a, ))
        management.call_command('sync_mobile', 'tmp', url='http://localhost:8000', verbosity=2, stdout=output,
                                portal=portal_b.name)

        zfile_global = zipfile.ZipFile(os.path.join('tmp', 'nolang', 'global.zip'))
        for finfo in zfile_global.infolist():
            ifile_global = zfile_global.open(finfo)
            if ifile_global.name.startswith('tiles/'):
                self.assertEqual(ifile_global.readline(), 'I am a png')
        zfile_trek = zipfile.ZipFile(os.path.join('tmp', 'nolang', '{}.zip'.format(trek.pk)))
        for finfo in zfile_trek.infolist():
            ifile_trek = zfile_trek.open(finfo)
            if ifile_global.name.startswith('tiles/'):
                self.assertEqual(ifile_trek.readline(), 'I am a png')
        self.assertIn("nolang/global.zip", output.getvalue())
        self.assertIn("nolang/{pk}.zip".format(pk=trek.pk), output.getvalue())

        self.assertFalse(os.path.exists(os.path.join('tmp', 'nolang', '{}.zip'.format(trek_not_same_portal.pk))))
Пример #24
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())
Пример #25
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')))
Пример #26
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())
Пример #27
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)
Пример #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.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())
Пример #29
0
 def setUp(self):
     super().setUp()
     self.trek = TrekWithPublishedPOIsFactory.create(published=True)