Exemplo n.º 1
0
 def test_get_not_found_community_collections(self):
     """
     Test retrieving all collections from an especific not found community
     """
     dspace =  self.dspace
     test_id = -1
     self.assertRaises(Community.DoesNotExist,lambda:Community.get_collections(dspace,test_id,expand=["parentCommunity"]))
Exemplo n.º 2
0
 def test_get_all_communities(self):
     """
     Test Retrieving all communities
     """
     dspace= self.dspace
     communities = Community.get_all(dspace)
     self.assertGreater(len(communities),0)
Exemplo n.º 3
0
 def test_get_community(self):
     """
     Test Retrieving an community by Id
     """
     dspace= self.dspace
     test_id = 2
     community = Community.get_community(dspace,test_id)
     self.assertEqual(community.id,test_id,"Get community by Id Fails")
Exemplo n.º 4
0
 def test_get_all_communities_with_limit(self):
     """
     Test Retrieving all communities with limit
     """
     dspace= self.dspace
     max_communities = 5
     communities = Community.get_all(dspace,limit=[max_communities])
     self.assertLessEqual(len(communities),max_communities)
Exemplo n.º 5
0
def get_collections_by_community(request,id):
    """
    Return all collections of the specified community.
    """
    try:
        collections =  Community.get_collections(dspace,id,**dict(request.query_params))
        return  Response(collections, status=status.HTTP_200_OK)
    except Community.DoesNotExist:
        raise Http404
Exemplo n.º 6
0
 def test_get_top_communities(self):
     """
     Test retrieving top level communities
     """
     dspace = self.dspace
     communities = Community.get_top_communities(dspace,expand=["parentCommunity"])
     self.assertIsNotNone(communities)
     for com in communities:
         self.assertIsNone(com['parentCommunity'])
Exemplo n.º 7
0
 def test_get_community_collections(self):
     """
     Test retrieving all collections from an especific community
     """
     dspace =  self.dspace
     test_id = 2
     collections = Community.get_collections(dspace,test_id,expand=["parentCommunity"])
     self.assertIsNotNone(collections)
     for collection in collections:
         collection_temp = Collection(dict(collection))
         self.assertEqual(test_id,collection_temp.parentCommunity["id"])
Exemplo n.º 8
0
def get_top_communities(request):
    """
    Return  top level communities array
    """
    communities = Community.get_top_communities(dspace,**dict(request.query_params))
    return Response(communities,status=status.HTTP_200_OK)
Exemplo n.º 9
0
 def get_object(self,id,**kwargs):
     try:
         community = Community.get_community(dspace,id,**dict(kwargs))
         return community
     except Community.DoesNotExist:
         raise Http404
Exemplo n.º 10
0
 def get(self,request,*args,**kwargs):
     communities = Community.get_all(dspace,**dict(self.request.query_params))
     return Response(communities, status=status.HTTP_200_OK)