コード例 #1
0
    def test_upload_file(self):
        """ Tests the upload of a file using moto.
        Ideally, creation of bucket should be moved to setUp(), but 
        moto creates new s3 mock with every decorator """

        self.connection = s3_tools.connect()
        self.test_bucket = self.connection.create_bucket('mybucket')
        self.test_file_location = 'test/assets/rob.png'

        s3_tools.upload_file_to_bucket(self.test_bucket,'foo', self.test_file_location)
        key = boto.s3.key.Key(self.test_bucket)
        key.key = 'foo'
        assert key.get_contents_as_string() == open(self.test_file_location).read()
コード例 #2
0
    def __init__(self, connection_params):
        self.logger = logging.getLogger(__name__)
        self.logger.debug("Got here")
        try:
            rmq_connection = pika.BlockingConnection(connection_params)
            self.logger.debug("Obtained connection to rmq")
        except Exception:
            self.logger.fatal("No connection to rmq available")

        self.rmq_channel = rmq_connection.channel()
        self.rmq_channel.basic_qos(prefetch_count=1)

        self.result_queue = self.rmq_channel.queue_declare(queue="user_images", durable=True)
        self.result_queue_name = self.result_queue.method.queue

        self.image_creation_queue = self.rmq_channel.queue_declare(queue="user_image_creation", durable=True)
        self.creation_queue_name = self.image_creation_queue.method.queue

        self.s3_connection = s3_tools.connect()