def test_get_resource_types(self): # this is the api call we are testing res_types = hydroshare.get_resource_types() # test that each resource type is a subclass of BaseResource type for res_type in res_types: self.assertEqual(issubclass(res_type, BaseResource), True)
def get_all_resources(self): """Yield all resources in the system as a single generator""" resource_types = hydroshare.get_resource_types() for qs in (res_model.objects.all() for res_model in resource_types): for resource in qs: yield resource
def test_get_resource_types(self): # this is the api call we are testing res_types = hydroshare.get_resource_types() # test that each resource type is a subclass of AbstractResource type for res_type in res_types: self.assertEqual(issubclass(res_type, AbstractResource), True) # not sure what else can be tested
def get_context_data(self, **kwargs): if 'user' in kwargs: try: u = User.objects.get(pk=int(kwargs['user'])) except: u = User.objects.get(username=kwargs['user']) else: try: u = User.objects.get(pk=int(self.request.GET['user'])) except: u = User.objects.get(username=self.request.GET['user']) resource_types = get_resource_types() res = [] for Resource in resource_types: res.extend([r for r in Resource.objects.filter(user=u)]) return { 'u' : u, 'resources' : res }
class ResourceCreateRequestValidator(ResourceUpdateRequestValidator): resource_type = serializers.ChoiceField( choices=zip([x.__name__ for x in hydroshare.get_resource_types()], [x.__name__ for x in hydroshare.get_resource_types()]), default='GenericResource')
class CreateResourceForm(UpdateResourceForm): resource_type = forms.ChoiceField( choices=zip([x.__name__ for x in hydroshare.get_resource_types()], [x.__name__ for x in hydroshare.get_resource_types()]))