예제 #1
0
    def test_map_image_other_language(self, mock_requests):
        if self.model is None:
            return  # Abstract test should not run

        SuperUserFactory.create(username='******', password='******')
        self.client.login(username='******', password='******')

        obj = self.modelfactory.create(geom='POINT(0 0)')

        # Initially, map image does not exists
        image_path = obj.get_map_image_path()
        if os.path.exists(image_path):
            os.remove(image_path)
        self.assertFalse(os.path.exists(image_path))

        # Mock Screenshot response
        mock_requests.get.return_value.status_code = 200
        mock_requests.get.return_value.content = b'*' * 100

        response = self.client.get(obj.map_image_url)
        self.assertEqual(response.status_code, 200)
        self.assertTrue(os.path.exists(image_path))

        mapimage_url = '%s%s?context&lang=fr' % (self.live_server_url,
                                                 obj.get_detail_url())
        screenshot_url = 'http://0.0.0.0:8001/?url=%s' % mapimage_url
        url_called = mock_requests.get.call_args_list[0]
        self.assertTrue(url_called.startswith(screenshot_url))
예제 #2
0
 def setUp(self):
     if os.path.exists(os.path.join('var', 'tmp_sync_rando')):
         shutil.rmtree(os.path.join('var', 'tmp_sync_rando'))
     if os.path.exists(os.path.join('var', 'tmp')):
         shutil.rmtree(os.path.join('var', 'tmp'))
     self.super_user = SuperUserFactory.create(username='******', password='******')
     self.simple_user = User.objects.create_user(username='******', password='******')
예제 #3
0
    def test_map_image_not_serve(self, mock_requests):
        if self.model is None:
            return  # Abstract test should not run
        app_settings['SENDFILE_HTTP_HEADER'] = 'X-Accel-Redirect'
        SuperUserFactory.create(username='******', password='******')
        self.client.login(username='******', password='******')

        obj = self.modelfactory.create(geom='POINT(0 0)')

        # Initially, map image does not exists
        image_path = obj.get_map_image_path()
        if os.path.exists(image_path):
            os.remove(image_path)
        self.assertFalse(os.path.exists(image_path))

        # Mock Screenshot response
        mock_requests.get.return_value.status_code = 200
        mock_requests.get.return_value.content = b'*' * 100

        response = self.client.get(obj.map_image_url)
        self.assertEqual(response.status_code, 200)
        self.assertTrue(os.path.exists(image_path))
예제 #4
0
 def test_creation_form_line(self):
     path = PathFactory.create(geom=LineString(Point(700000, 6600000), Point(700300, 6600300), srid=settings.SRID))
     self.super_user = SuperUserFactory.create(username='******', password='******')
     self.client.login(username='******', password='******')
     data = self.get_good_data()
     data['structure'] = StructureFactory.create().pk
     data['topology'] = '{"paths": [%s], "positions":{"0":[0,1]}}' % path.pk,
     response = self.client.post('%s' % (Intervention.get_add_url()),
                                 data)
     self.assertEqual(PathAggregation.objects.count(), 1)
     self.assertEqual(response.status_code, 302)
     self.assertEqual(Intervention.objects.first().geom, path.geom)
     self.assertEqual(Intervention.objects.first().target.kind, 'INTERVENTION')
예제 #5
0
    def setUp(self):
        self.user = SuperUserFactory.create(password='******')

        self.theme = ThemeFactory.create(label="Theme 1")
        self.theme_2 = ThemeFactory.create(label="Theme 2")
        self.theme_other = ThemeFactory.create(label="Autre theme")
        self.difficulty_1 = DifficultyLevelFactory.create(difficulty="Dif 1")
        self.difficulty_2 = DifficultyLevelFactory.create(difficulty="Dif 2")
        self.difficulty_3 = DifficultyLevelFactory.create(difficulty="Dif 3")
        self.trek = TrekFactory.create(
            geom='SRID=%s;LINESTRING(0 0, 1 0, 2 0)' % settings.SRID,
            difficulty=self.difficulty_2)
        self.trek.themes.add(self.theme, self.theme_2)
예제 #6
0
    def setUp(self):
        self.user = SuperUserFactory.create(password='******')
        self.content = POIFactory.create(geom='SRID=%s;POINT(1 1)' %
                                         settings.SRID)

        self.picture = AttachmentFactory(
            content_object=self.content,
            attachment_file=get_dummy_uploaded_image(),
        )
        self.trek = TrekFactory.create(
            geom='SRID=%s;LINESTRING(0 0, 1 0, 2 0)' % settings.SRID)
        self.picture_2 = AttachmentFactory(
            content_object=self.trek,
            attachment_file=get_dummy_uploaded_image(),
        )
예제 #7
0
    def setUp(self):
        self.user = SuperUserFactory.create(password='******')
        self.content = POIFactory.create(geom='SRID=%s;POINT(1 1)' %
                                         settings.SRID)

        self.picture = AttachmentFactory(
            content_object=self.content,
            title='img1',
            attachment_file=get_dummy_uploaded_image())
        self.trek = TrekFactory.create(
            geom='SRID=%s;LINESTRING(0 0, 1 0, 2 0)' % settings.SRID)
        self.picture_2 = AttachmentFactory(
            content_object=self.trek,
            title='img2',
            attachment_file=get_dummy_uploaded_image())
        if os.path.exists(settings.MEDIA_ROOT):
            shutil.rmtree(settings.MEDIA_ROOT)
        os.makedirs(settings.MEDIA_ROOT)
예제 #8
0
 def setUp(self):
     self.user = SuperUserFactory.create(password='******')
     self.direction = BladeDirectionFactory.create()
예제 #9
0
 def setUp(self):
     self.user = SuperUserFactory.create(password='******')
     self.type_information_desk = InformationDeskTypeFactory(label="Office")
예제 #10
0
 def setUp(self):
     self.user = SuperUserFactory.create(password='******')
     self.infra = InfrastructureConditionFactory.create()
예제 #11
0
 def setUp(self):
     self.user = SuperUserFactory.create(password='******')
     self.direction = BladeDirectionFactory.create()
예제 #12
0
 def setUp(self):
     self.user = SuperUserFactory.create(password='******')
     self.color = BladeColorFactory.create()
예제 #13
0
 def setUp(self):
     self.super_user = SuperUserFactory.create(username='******',
                                               password='******')
     self.simple_user = User.objects.create_user(username='******',
                                                 password='******')
예제 #14
0
 def setUp(self):
     self.admin = SuperUserFactory.create(password='******')
     self.pathmanager = factories.PathManagerFactory.create(password='******')
     self.trekmanager = factories.TrekkingManagerFactory.create(
         password='******')
     self.user = factories.UserFactory.create(password='******')
예제 #15
0
 def setUp(self):
     self.admin = SuperUserFactory.create(password='******')
     self.pathmanager = factories.PathManagerFactory.create(password='******')
     self.trekmanager = factories.TrekkingManagerFactory.create(password='******')
     self.user = factories.UserFactory.create(password='******')
예제 #16
0
 def setUpClass(cls):
     super(ZoningAdminTest, cls).setUpClass()
     cls.user = SuperUserFactory.create(password='******')
예제 #17
0
 def setUp(self):
     self.user = SuperUserFactory.create(password='******')
     self.color = BladeColorFactory.create()
예제 #18
0
 def setUp(self):
     self.user = SuperUserFactory.create()
     self.client.force_login(self.user)
예제 #19
0
 def setUp(self):
     self.user = SuperUserFactory.create(password='******')
     self.infra = InfrastructureConditionFactory.create()