def test_objects_not_returns_folders_inside_bucket(self, requests): resp = self.make_response(self.bucket_with_folder, 200) requests.get.return_value = resp objects = S3Client().objects('test-pybossa') assert objects == [], objects
def test_objects_return_list_of_object_names_in_a_bucket(self, requests): resp = self.make_response(self.bucket_with_content, 200) requests.get.return_value = resp objects = S3Client().objects('test-pybossa') assert objects == [u'16535035993_1080p.mp4', u'BFI-demo.mp4'], objects
def test_objects_return_empty_list_for_an_empty_bucket(self, requests): resp = self.make_response(self.empty_bucket, 200) requests.get.return_value = resp objects = S3Client().objects('test-pybossa') assert objects == [], objects
def objects(bucket): try: bucket_content = S3Client().objects(bucket) return Response(json.dumps(bucket_content), mimetype='application/json') except (NoSuchBucket, PrivateBucket) as e: status_code = e.status_code error = dict(action='GET', status="failed", status_code=status_code, exception_msg=str(e)) return Response(json.dumps(error), status=status_code, mimetype='application/json')
def test_objects_raises_PrivateBucket_if_bucket_is_private(self, requests): resp = self.make_response(self.no_such_bucket, 403) requests.get.return_value = resp assert_raises(PrivateBucket, S3Client().objects, 'test-pybossa')
def test_objects_raises_NoSuchBucket_if_bucket_does_not_exist( self, requests): resp = self.make_response(self.no_such_bucket, 404) requests.get.return_value = resp assert_raises(NoSuchBucket, S3Client().objects, 'test-pybossa')