def get_authenticated_client(self, role_name): """ Helper for concisely obtaining a `rest_framework.test.APIClient` instance, authenticated with a user having some specific role. """ # create a user with the specified role user = UserFactory.create() user.groups.add(Group.objects.get(name=role_name)) # pylint: disable=no-member # create an APIClient and force auth client = APIClient() client.force_authenticate(user) return client
def setUp(self): self.user = UserFactory.create() super(TestPipelineUserRoles, self).setUp()
def setUp(self): self.user = UserFactory.create() super(TestPipelineUserRoles, self).setUp()