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))
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='******')
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))
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')
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)
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(), )
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)
def setUp(self): self.user = SuperUserFactory.create(password='******') self.direction = BladeDirectionFactory.create()
def setUp(self): self.user = SuperUserFactory.create(password='******') self.type_information_desk = InformationDeskTypeFactory(label="Office")
def setUp(self): self.user = SuperUserFactory.create(password='******') self.infra = InfrastructureConditionFactory.create()
def setUp(self): self.user = SuperUserFactory.create(password='******') self.color = BladeColorFactory.create()
def setUp(self): self.super_user = SuperUserFactory.create(username='******', password='******') self.simple_user = User.objects.create_user(username='******', password='******')
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='******')
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='******')
def setUpClass(cls): super(ZoningAdminTest, cls).setUpClass() cls.user = SuperUserFactory.create(password='******')
def setUp(self): self.user = SuperUserFactory.create() self.client.force_login(self.user)