def setUp(self): self.user = UserFactory(password='******') perm = Permission.objects.get_by_natural_key('add_report', 'feedback', 'report') self.user.user_permissions.add(perm) self.login_url = '/login/'
def setUp(self): self.user = UserFactory(password='******') perm = Permission.objects.get_by_natural_key('add_report', 'feedback', 'report') self.user.user_permissions.add(perm) self.login_url = smart_urljoin(self.live_server_url, '/login/') self.session = requests.Session()
def test_navbar_permissions(self): user = UserFactory.create(password='******') user.user_permissions.add(Permission.objects.get(codename='read_dummymodel')) self.client.login(username=user.username, password='******') response = self.client.get('/dummymodel/list/') self.assertContains(response, 'href="/dummymodel/add/">+</a>') self.assertContains(response, '<a href="/dummymodel/list/" title="') self.assertNotContains(response, 'href="/mushroomspot/add/">+</a>') self.assertNotContains(response, '<a href="/mushroomspot/list/" title="')
def setUp(self): super(TrailKmlGPXTest, self).setUp() self.user = UserFactory.create(is_staff=True, is_superuser=True) self.client.force_login(self.user) self.trail = TrailFactory.create(comments='exportable trail') self.gpx_response = self.client.get(reverse('core:trail_gpx_detail', args=('en', self.trail.pk, 'slug'))) self.gpx_parsed = BeautifulSoup(self.gpx_response.content, 'lxml') self.kml_response = self.client.get(reverse('core:trail_kml_detail', args=('en', self.trail.pk, 'slug')))
def setUp(self): self.user = UserFactory.create(password='******') self.client.login(username=self.user.username, password='******') for perm in Permission.objects.exclude(codename='can_bypass_structure'): self.user.user_permissions.add(perm) self.user.is_staff = True self.user.save() p = self.user.profile structure = StructureFactory(name="This") p.structure = structure p.save() self.sealing = SealingFactory.create(structure=structure)
def setUp(self): self.user = UserFactory.create(password='******') self.client.login(username=self.user.username, password='******') self.user.user_permissions.add(Permission.objects.get(codename='add_draft_path')) for perm in Permission.objects.exclude(codename='can_bypass_structure'): self.user.user_permissions.add(perm) self.user.is_staff = True self.user.save() p = self.user.profile structure = StructureFactory(name="This") p.structure = structure p.save() self.infra = InfrastructureConditionFactory.create(structure=structure)
def test_logentry(self): user = UserFactory.create() object = PathFactory.create() logentry = LogEntry.objects.log_action( user_id=user.pk, content_type_id=object.get_content_type_id(), object_id=object.pk, object_repr=force_text(object), action_flag=ADDITION) self.assertEqual('Added', logentry.action_flag_display) self.assertIn('{0}'.format(localize(logentry.action_time)), logentry.action_time_display) self.assertIn(object.name, logentry.object_display)
def test_map_image_not_published_no_permission(self, mock_requests): if self.model is None: return # Abstract test should not run UserFactory.create(username='******', password='******') self.client.login(username='******', password='******') obj = self.modelfactory.create(geom='POINT(0 0)', published=False) # 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, 403) self.assertFalse(os.path.exists(image_path))
def test_draft_permission_detail(self): path = PathFactory(name="DRAFT_PATH", draft=True) user = UserFactory(password='******') p = user.profile p.save() perm_add_draft_path = Permission.objects.get(codename='add_draft_path') perm_delete_draft_path = Permission.objects.get(codename='delete_draft_path') perm_change_draft_path = Permission.objects.get(codename='change_draft_path') perm_read_path = Permission.objects.get(codename='read_path') user.user_permissions.add(perm_delete_draft_path) user.user_permissions.add(perm_read_path) user.user_permissions.add(perm_change_draft_path) user.user_permissions.add(perm_add_draft_path) self.client.login(username=user.username, password='******') response = self.client.get(path.get_update_url()) self.assertEqual(response.status_code, 200) self.assertContains(response, path.get_delete_url())
def setUp(self): self.user = UserFactory.create(username='******', password='******') success = self.client.login(username=self.user.username, password='******') self.assertTrue(success)
def setUp(self): self.user = UserFactory.create(password='******')