Example #1
0
 def setUp(self):
     super(TestUserNodes, self).setUp()
     self.user_one = UserFactory.build()
     self.user_one.set_password('justapoorboy')
     self.user_one.social['twitter'] = 'howtopizza'
     self.user_one.save()
     self.auth_one = (self.user_one.username, 'justapoorboy')
     self.user_two = UserFactory.build()
     self.user_two.set_password('justapoorboy')
     self.user_two.save()
     self.auth_two = (self.user_two.username, 'justapoorboy')
     self.public_project_user_one = ProjectFactory(title="Public Project User One",
                                                   is_public=True,
                                                   creator=self.user_one)
     self.private_project_user_one = ProjectFactory(title="Private Project User One",
                                                    is_public=False,
                                                    creator=self.user_one)
     self.public_project_user_two = ProjectFactory(title="Public Project User Two",
                                                   is_public=True,
                                                   creator=self.user_two)
     self.private_project_user_two = ProjectFactory(title="Private Project User Two",
                                                    is_public=False,
                                                    creator=self.user_two)
     self.deleted_project_user_one = FolderFactory(title="Deleted Project User One",
                                                   is_public=False,
                                                   creator=self.user_one,
                                                   is_deleted=True)
     self.folder = FolderFactory()
     self.deleted_folder = FolderFactory(title="Deleted Folder User One",
                                         is_public=False,
                                         creator=self.user_one,
                                         is_deleted=True)
     self.dashboard = DashboardFactory()
Example #2
0
    def setUp(self):
        super(TestUserRoutesNodeRoutes, self).setUp()
        self.user_one = AuthUserFactory()
        self.user_one.social['twitter'] = 'howtopizza'
        self.user_two = AuthUserFactory()
        self.public_project_user_one = ProjectFactory(
            title="Public Project User One",
            is_public=True,
            creator=self.user_one)
        self.private_project_user_one = ProjectFactory(
            title="Private Project User One",
            is_public=False,
            creator=self.user_one)
        self.public_project_user_two = ProjectFactory(
            title="Public Project User Two",
            is_public=True,
            creator=self.user_two)
        self.private_project_user_two = ProjectFactory(
            title="Private Project User Two",
            is_public=False,
            creator=self.user_two)
        self.deleted_project_user_one = FolderFactory(
            title="Deleted Project User One",
            is_public=False,
            creator=self.user_one,
            is_deleted=True)

        self.folder = FolderFactory()
        self.deleted_folder = FolderFactory(title="Deleted Folder User One",
                                            is_public=False,
                                            creator=self.user_one,
                                            is_deleted=True)
        self.dashboard = DashboardFactory()
Example #3
0
    def test_serialize_folder_containing_folder_increases_size_by_one(self):
        outer_folder = FolderFactory(creator=self.user)

        folder_hgrid = rubeus.to_project_hgrid(outer_folder, self.auth)

        inner_folder = FolderFactory(creator=self.user)
        outer_folder.add_pointer(inner_folder, self.auth)

        new_hgrid = rubeus.to_project_hgrid(outer_folder, self.auth)
        assert_equal(len(folder_hgrid) + 1, len(new_hgrid))
    def setUp(self):
        super(TestRegistrationFiltering, self).setUp()
        self.user_one = AuthUserFactory()
        self.user_two = AuthUserFactory()
        self.project_one = ProjectFactory(title="Project One",
                                          description='Two',
                                          is_public=True,
                                          creator=self.user_one,
                                          category='hypothesis')
        self.project_two = ProjectFactory(title="Project Two",
                                          description="One Three",
                                          is_public=True,
                                          creator=self.user_one)
        self.project_three = ProjectFactory(title="Three",
                                            is_public=True,
                                            creator=self.user_two)

        self.private_project_user_one = ProjectFactory(
            title="Private Project User One",
            is_public=False,
            creator=self.user_one)
        self.private_project_user_two = ProjectFactory(
            title="Private Project User Two",
            is_public=False,
            creator=self.user_two)

        self.project_one.add_tag('tag1',
                                 Auth(self.project_one.creator),
                                 save=False)
        self.project_one.add_tag('tag2',
                                 Auth(self.project_one.creator),
                                 save=False)
        self.project_one.save()
        self.project_two.add_tag('tag1',
                                 Auth(self.project_two.creator),
                                 save=True)
        self.project_two.save()

        self.project_one_reg = RegistrationFactory(creator=self.user_one,
                                                   project=self.project_one,
                                                   is_public=True)
        self.project_two_reg = RegistrationFactory(creator=self.user_one,
                                                   project=self.project_two,
                                                   is_public=True)
        self.project_three_reg = RegistrationFactory(
            creator=self.user_two, project=self.project_three, is_public=True)
        self.private_project_user_one_reg = RegistrationFactory(
            creator=self.user_one,
            project=self.private_project_user_one,
            is_public=False)
        self.private_project_user_two_reg = RegistrationFactory(
            creator=self.user_two,
            project=self.private_project_user_two,
            is_public=False)

        self.folder = FolderFactory()
        self.dashboard = DashboardFactory()

        self.url = "/{}registrations/".format(API_BASE)
Example #5
0
    def test_dashboard_adding_one_folder_increases_size_by_one_in_hgrid_representation(self):
        folder = FolderFactory(creator=self.user)
        self.dash.add_pointer(folder, self.auth)

        project = ProjectFactory(creator=self.user)
        folder.add_pointer(project,self.auth)

        dash_hgrid = rubeus.to_project_hgrid(self.dash, self.auth)
        assert_equal(len(dash_hgrid), len(self.init_dash_hgrid) + 1)
Example #6
0
    def test_dashboard_adding_one_folder_does_not_remove_smart_folders(self):
        folder = FolderFactory(creator=self.user)
        self.dash.add_pointer(folder, self.auth)

        dash_hgrid = rubeus.to_project_hgrid(self.dash, self.auth)

        assert_true(
            {ALL_MY_PROJECTS_NAME, ALL_MY_REGISTRATIONS_NAME, folder.title
             } <= {node_hgrid['name']
                   for node_hgrid in dash_hgrid})
Example #7
0
    def test_view_project_pointer_count_excludes_folders(self):
        user = UserFactory()
        pointer_project = ProjectFactory(is_public=True)  # project that points to another project
        pointed_project = ProjectFactory(creator=user)  # project that other project points to
        pointer_project.add_pointer(pointed_project, Auth(pointer_project.creator), save=True)

        # Project is in a dashboard folder
        folder = FolderFactory(creator=pointed_project.creator)
        folder.add_pointer(pointed_project, Auth(pointed_project.creator), save=True)

        result = _view_project(pointed_project, Auth(pointed_project.creator))
        # pointer_project is included in count, but not folder
        assert_equal(result['node']['points'], 1)
Example #8
0
    def test_collection_serialization(self):
        collection = FolderFactory(creator=self.user)
        req = make_drf_request()
        result = CollectionSerializer(collection, context={'request': req}).data
        data = result['data']
        assert_equal(data['id'], collection._id)
        assert_equal(data['type'], 'collections')

        # Attributes
        attributes = data['attributes']
        assert_equal(attributes['title'], collection.title)
        assert_equal(attributes['date_created'], collection.date_created.isoformat())
        assert_equal(attributes['date_modified'], collection.date_modified.isoformat())

        # Relationships
        relationships = data['relationships']
        assert_in('node_links', relationships)
        # Bunch of stuff in Nodes that should not be in Collections
        assert_not_in('contributors', relationships)
        assert_not_in('files', relationships)
        assert_not_in('parent', relationships)
        assert_not_in('registrations', relationships)
        assert_not_in('forked_from', relationships)
Example #9
0
    def test_serialized_folder_is_valid_folder(self):
        folder = FolderFactory(creator=self.user)

        folder_hgrid = rubeus.to_project_hgrid(folder, self.auth)

        assert_equal(folder_hgrid, [])
Example #10
0
 def test_cannot_return_folder_at_node_detail_endpoint(self):
     folder = FolderFactory(creator=self.user)
     res = self.app.get('/{}nodes/{}/'.format(API_BASE, folder._id), auth=self.user.auth, expect_errors=True)
     assert_equal(res.status_code, 404)