def setUp(self):
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.project = ProjectFactory.build(owner=self.group)

        self.view = ProjectViewSet.as_view({"post": "create"})
        self.factory = APIRequestFactory()
        self.url = reverse("api:v2:project-list")
        self.request = self.factory.post(self.url, {"name": self.project.name, "description": self.project.description})
    def setUp(self):
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.project = ProjectFactory.build(owner=self.group)

        self.view = ProjectViewSet.as_view({'post': 'create'})
        self.factory = APIRequestFactory()
        self.url = reverse('api:v2:project-list')
        self.request = self.factory.post(self.url, {
            'name': self.project.name,
            'description': self.project.description
        })
    def setUp(self):
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.project = ProjectFactory.build(owner=self.group)

        self.view = ProjectViewSet.as_view({'post': 'create'})
        self.factory = APIRequestFactory()
        self.url = reverse('api:v2:project-list')
        self.request = self.factory.post(
            self.url, {
                'name': self.project.name,
                'description': self.project.description
            })
    def setUp(self):
        self.anonymous_user = AnonymousUserFactory()

        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.membership = GroupMembershipFactory.create(
            user=self.user, group=self.group, is_leader=True
        )
        self.group.user_set.add(self.user)
        self.project = ProjectFactory.create(
            owner=self.group, created_by=self.user
        )
        self.enddated_instance = InstanceFactory.create(
            created_by=self.user, end_date=timezone.now(), project=self.project
        )

        self.user2 = UserFactory.create()
        self.group2 = GroupFactory.create(name=self.user2.username)
        self.membership2 = GroupMembershipFactory.create(
            user=self.user2, group=self.group2, is_leader=True
        )
        self.group2.user_set.add(self.user2)
        self.project2 = ProjectFactory.create(
            owner=self.group2, created_by=self.user2
        )

        self.not_user = UserFactory.create()
        self.not_group = GroupFactory.create(name=self.not_user.username)
        self.not_membership = GroupMembershipFactory.create(
            user=self.not_user, group=self.not_group, is_leader=True
        )
        self.not_group.user_set.add(self.not_user)
        self.not_project = ProjectFactory.create(
            owner=self.not_group, created_by=self.not_user
        )

        self.unsaved_project = ProjectFactory.build(
            owner=self.group, created_by=self.user
        )

        list_url = reverse('api:v2:project-list')
        detail_url = reverse('api:v2:project-detail', args=(self.project.id, ))

        self.create_view = ProjectViewSet.as_view({'post': 'create'})
        self.delete_view = ProjectViewSet.as_view({'delete': 'destroy'})
        self.detail_view = ProjectViewSet.as_view({'get': 'retrieve'})
        self.list_view = ProjectViewSet.as_view({'get': 'list'})
        self.update_view = ProjectViewSet.as_view({'patch': 'partial_update'})

        self.factory = APIRequestFactory()
        self.bad_create_request = self.factory.post(list_url)
        self.create_request = self.factory.post(
            list_url, {
                'name': self.unsaved_project.name,
                'description': self.unsaved_project.description,
                'owner': self.group.name
            }
        )
        self.delete_request = self.factory.delete(detail_url)
        self.detail_request = self.factory.get(detail_url)
        self.list_request = self.factory.get(list_url)
        self.updated_project_data = {
            'name': 'updated name',
            'description': 'updated description'
        }
        self.update_request = self.factory.patch(
            detail_url, self.updated_project_data
        )
Exemple #5
0
    def setUp(self):
        self.anonymous_user = AnonymousUserFactory()

        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.membership = GroupMembershipFactory.create(user=self.user,
                                                        group=self.group,
                                                        is_leader=True)
        self.group.user_set.add(self.user)
        self.project = ProjectFactory.create(owner=self.group,
                                             created_by=self.user)
        self.enddated_instance = InstanceFactory.create(
            created_by=self.user,
            end_date=timezone.now(),
            project=self.project)

        self.user2 = UserFactory.create()
        self.group2 = GroupFactory.create(name=self.user2.username)
        self.membership2 = GroupMembershipFactory.create(user=self.user2,
                                                         group=self.group2,
                                                         is_leader=True)
        self.group2.user_set.add(self.user2)
        self.project2 = ProjectFactory.create(owner=self.group2,
                                              created_by=self.user2)

        self.not_user = UserFactory.create()
        self.not_group = GroupFactory.create(name=self.not_user.username)
        self.not_membership = GroupMembershipFactory.create(
            user=self.not_user, group=self.not_group, is_leader=True)
        self.not_group.user_set.add(self.not_user)
        self.not_project = ProjectFactory.create(owner=self.not_group,
                                                 created_by=self.not_user)

        self.unsaved_project = ProjectFactory.build(owner=self.group,
                                                    created_by=self.user)

        list_url = reverse('api:v2:project-list')
        detail_url = reverse('api:v2:project-detail', args=(self.project.id, ))

        self.create_view = ProjectViewSet.as_view({'post': 'create'})
        self.delete_view = ProjectViewSet.as_view({'delete': 'destroy'})
        self.detail_view = ProjectViewSet.as_view({'get': 'retrieve'})
        self.list_view = ProjectViewSet.as_view({'get': 'list'})
        self.update_view = ProjectViewSet.as_view({'patch': 'partial_update'})

        self.factory = APIRequestFactory()
        self.bad_create_request = self.factory.post(list_url)
        self.create_request = self.factory.post(
            list_url, {
                'name': self.unsaved_project.name,
                'description': self.unsaved_project.description,
                'owner': self.group.name
            })
        self.delete_request = self.factory.delete(detail_url)
        self.detail_request = self.factory.get(detail_url)
        self.list_request = self.factory.get(list_url)
        self.updated_project_data = {
            'name': 'updated name',
            'description': 'updated description'
        }
        self.update_request = self.factory.patch(detail_url,
                                                 self.updated_project_data)