def test_validate_bucket_created(self):
     bucket, user_content = self.create_bucket_and_validate_users()
     # create upload file
     str_content = Helper.rand_string("randomString") + Helper.rand_string(
         "randomNumber")
     fileName = Helper.rand_string("randomString")
     bucket_id = user_content['engagement_manual_id'] + "_" + user_content[
         'vfName'].lower()
     Wait.bucket_to_create(bucket_id)
     bucket = API.Rados.get_bucket(bucket_id)
     assertTrue(API.Rados.is_bucket_ready(bucket_id))
     key = bucket.new_key(fileName + '.dat')
     key.set_contents_from_string(str_content)
     pprint(key.generate_url(expires_in=400))
     #         DOWNLOAD AN OBJECT (TO A FILE)
     key = bucket.get_key(fileName + '.dat')
     key.get_contents_to_filename('/home/' + fileName + '.dat')
     key.delete()
    def create_bucket_and_validate_users(self):
        user_content = API.VirtualFunction.create_engagement(
            wait_for_gitlab=True)

        API.VirtualFunction.set_eng_stage(user_content,
                                          Constants.EngagementStages.ACTIVE)
        bucket_id = user_content['engagement_manual_id'] + \
            "_" + user_content['vfName'].lower()
        Wait.bucket_to_create(bucket_id)
        bucket = API.Rados.get_bucket(bucket_id)
        assertTrue(API.Rados.is_bucket_ready(bucket_id))
        assertTrue(bucket != "None")
        # validate users added to bucket
        grants = API.Rados.get_bucket_grants(bucket_id)
        count = 0
        for g in grants:
            if g.id == user_content['uuid']:
                count = +1

        assertTrue(count > 0)
        return bucket, user_content