def get(self, request, file_mgr_name, system_id=None, file_path=None): """GET handler.""" if file_mgr_name not in [ PublicElasticFileManager.NAME, 'community', 'published' ]: return HttpResponseBadRequest('Wrong Manager') if file_mgr_name == PublicElasticFileManager.NAME: if not request.user.is_authenticated: ag = get_user_model().objects.get( username='******').agave_oauth.client else: ag = request.user.agave_oauth.client if system_id is None or (file_path is None or file_path == '/'): system_id = PublicElasticFileManager.DEFAULT_SYSTEM_ID file_mgr = PublicElasticFileManager(ag) elif file_mgr_name == 'community': if not request.user.is_authenticated: ag = get_user_model().objects.get( username='******').agave_oauth.client else: ag = request.user.agave_oauth.client file_mgr = CommunityFileManager(ag) elif file_mgr_name == 'published': if not request.user.is_authenticated: ag = get_user_model().objects.get( username='******').agave_oauth.client else: ag = request.user.agave_oauth.client file_mgr = PublishedFileManager(ag) offset = int(request.GET.get('offset', 0)) limit = int(request.GET.get('limit', 100)) status = request.GET.get('status', 'published') listing = file_mgr.listing(system_id, file_path, offset=offset, limit=limit, status=status) # logger.debug(listing.to_dict()['children'][0]) return JsonResponse(listing.to_dict())
def test_trash_raises(self): mock_ac = MagicMock() fm = CommunityFileManager(mock_ac) with self.assertRaises(ApiException): fm.trash()
def test_requires_auth(self): mock_ac = MagicMock() fm = CommunityFileManager(mock_ac) self.assertEqual(fm.requires_auth, False)
def test_listing(self, mock_afm): mock_ac = MagicMock() fm = CommunityFileManager(mock_ac) fm.listing('test.system', '/') mock_afm.listing.assert_called_with(mock_ac, 'test.system', '/', 0, 100)