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})
Esempio n. 2
0
    def setUp(self):
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.project = ProjectFactory.create(owner=self.group)

        self.not_user = UserFactory.create()
        self.not_group = GroupFactory.create(name=self.not_user.username)

        self.view = ProjectViewSet.as_view({'delete': 'destroy'})
        self.factory = APIRequestFactory()
        self.url = reverse('api:v2:project-detail', args=(self.project.id, ))
        self.request = self.factory.delete(self.url)
    def setUp(self):
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.project = ProjectFactory.create(owner=self.group)

        self.not_user = UserFactory.create()
        self.not_group = GroupFactory.create(name=self.not_user.username)

        self.view = ProjectViewSet.as_view({"delete": "destroy"})
        self.factory = APIRequestFactory()
        self.url = reverse("api:v2:project-detail", args=(self.project.id,))
        self.request = self.factory.delete(self.url)
Esempio n. 4
0
    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.create(owner=self.group)

        user2 = UserFactory.create()
        group2 = GroupFactory.create(name=user2.username)
        ProjectFactory.create(owner=group2)

        self.view = ProjectViewSet.as_view({"get": "list"})
        factory = APIRequestFactory()
        url = reverse("api:v2:project-list")
        self.request = factory.get(url)
Esempio n. 6
0
    def setUp(self):
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.project = ProjectFactory.create(owner=self.group)

        user2 = UserFactory.create()
        group2 = GroupFactory.create(name=user2.username)
        ProjectFactory.create(owner=group2)

        self.view = ProjectViewSet.as_view({'get': 'retrieve'})
        factory = APIRequestFactory()
        url = reverse('api_v2:project-detail', args=(self.project.id,))
        self.request = factory.get(url)
Esempio n. 7
0
    def setUp(self):
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.project = ProjectFactory.create(owner=self.group)

        user2 = UserFactory.create()
        group2 = GroupFactory.create(name=user2.username)
        ProjectFactory.create(owner=group2)

        self.view = ProjectViewSet.as_view({'get': 'retrieve'})
        factory = APIRequestFactory()
        url = reverse('api:v2:project-detail', args=(self.project.id, ))
        self.request = factory.get(url)
Esempio n. 8
0
    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.create(owner=self.group)

        self.not_user = UserFactory.create()
        self.not_group = GroupFactory.create(name=self.not_user.username)
        self.not_project = ProjectFactory.create(owner=self.not_group)

        self.updated_project_data = {"name": "updated name", "description": "updated description"}

        self.factory = APIRequestFactory()
        self.url = reverse("api:v2:project-detail", args=(self.project.id,))
        self.request = self.factory.put(
            self.url,
            {"name": self.updated_project_data["name"], "description": self.updated_project_data["description"]},
        )

        self.view = ProjectViewSet.as_view({"put": "update"})
Esempio n. 10
0
    def setUp(self):
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.project = ProjectFactory.create(owner=self.group)

        self.not_user = UserFactory.create()
        self.not_group = GroupFactory.create(name=self.not_user.username)
        self.not_project = ProjectFactory.create(owner=self.not_group)

        self.updated_project_data = {
            'name': 'updated name',
            'description': 'updated description'
        }

        self.factory = APIRequestFactory()
        self.url = reverse('api_v2:project-detail', args=(self.project.id,))
        self.request = self.factory.put(self.url, {
            'name': self.updated_project_data['name'],
            'description': self.updated_project_data['description']
        })

        self.view = ProjectViewSet.as_view({'put': 'update'})
Esempio n. 11
0
    def setUp(self):
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.group = GroupFactory.create(name=self.user.username)
        self.project = ProjectFactory.create(owner=self.group)

        self.not_user = UserFactory.create()
        self.not_group = GroupFactory.create(name=self.not_user.username)
        self.not_project = ProjectFactory.create(owner=self.not_group)

        self.updated_project_data = {
            'name': 'updated name',
            'description': 'updated description'
        }

        self.factory = APIRequestFactory()
        self.url = reverse('api:v2:project-detail', args=(self.project.id, ))
        self.request = self.factory.put(
            self.url, {
                'name': self.updated_project_data['name'],
                'description': self.updated_project_data['description']
            })

        self.view = ProjectViewSet.as_view({'put': 'update'})
    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
        )
Esempio n. 13
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)