def setUp(self):
     self.dynamodb = Layer2()
     self.hash_key_name = 'forum_name'
     self.hash_key_proto_value = ''
     self.range_key_name = 'subject'
     self.range_key_proto_value = ''
     self.table_name = 'sample_data_%s' % int(time.time())
Esempio n. 2
0
 def setUp(self):
     self.alt_provider = Mock(spec=boto.provider.Provider)
     self.alt_provider.host = None
     self.alt_provider.host_header = None
     self.alt_provider.port = None
     self.alt_provider.secret_key = 'alt_secret_key'
     self.layer2 = Layer2(None, None, provider=self.alt_provider)
Esempio n. 3
0
def connect_dynamodb(aws_access_key_id=None,
                     aws_secret_access_key=None,
                     **kwargs):
    """
    :type aws_access_key_id: string
    :param aws_access_key_id: Your AWS Access Key ID

    :type aws_secret_access_key: string
    :param aws_secret_access_key: Your AWS Secret Access Key

    :rtype: :class:`boto.dynamodb.layer2.Layer2`
    :return: A connection to the Layer2 interface for DynamoDB.
    """
    from boto.dynamodb.layer2 import Layer2
    return Layer2(aws_access_key_id, aws_secret_access_key, **kwargs)
Esempio n. 4
0
def connect_cloudsearch(aws_access_key_id=None,
                        aws_secret_access_key=None,
                        **kwargs):
    """
    :type aws_access_key_id: string
    :param aws_access_key_id: Your AWS Access Key ID

    :type aws_secret_access_key: string
    :param aws_secret_access_key: Your AWS Secret Access Key

    :rtype: :class:`boto.ec2.autoscale.CloudSearchConnection`
    :return: A connection to Amazon's CloudSearch service
    """
    from boto.cloudsearch.layer2 import Layer2
    return Layer2(aws_access_key_id, aws_secret_access_key, **kwargs)
Esempio n. 5
0
 def setUp(self):
     self.dynamodb = Layer2()
     self.schema = Schema.create(('foo', 'N'), ('bar', 'S'))
     self.table_name = 'testtable%s' % int(time.time())
Esempio n. 6
0
    def test_layer2_basic(self):
        print '--- running Amazon DynamoDB Layer2 tests ---'
        c = Layer2()

        # First create a schema for the table
        hash_key_name = 'forum_name'
        hash_key_proto_value = ''
        range_key_name = 'subject'
        range_key_proto_value = ''
        schema = c.create_schema(hash_key_name, hash_key_proto_value,
                                 range_key_name, range_key_proto_value)

        # Create another schema without a range key
        schema2 = c.create_schema('post_id', '')

        # Now create a table
        index = int(time.time())
        table_name = 'test-%d' % index
        read_units = 5
        write_units = 5
        table = c.create_table(table_name, schema, read_units, write_units)
        assert table.name == table_name
        assert table.schema.hash_key_name == hash_key_name
        assert table.schema.hash_key_type == get_dynamodb_type(hash_key_proto_value)
        assert table.schema.range_key_name == range_key_name
        assert table.schema.range_key_type == get_dynamodb_type(range_key_proto_value)
        assert table.read_units == read_units
        assert table.write_units == write_units

        # Create the second table
        table2_name = 'test-%d' % (index + 1)
        table2 = c.create_table(table2_name, schema2, read_units, write_units)

        # Wait for table to become active
        table.refresh(wait_for_active=True)
        table2.refresh(wait_for_active=True)

        # List tables and make sure new one is there
        table_names = c.list_tables()
        assert table_name in table_names
        assert table2_name in table_names

        # Update the tables ProvisionedThroughput
        new_read_units = 10
        new_write_units = 5
        table.update_throughput(new_read_units, new_write_units)

        # Wait for table to be updated
        table.refresh(wait_for_active=True)
        assert table.read_units == new_read_units
        assert table.write_units == new_write_units

        # Put an item
        item1_key = 'Amazon DynamoDB'
        item1_range = 'DynamoDB Thread 1'
        item1_attrs = {
            'Message': 'DynamoDB thread 1 message text',
            'LastPostedBy': 'User A',
            'Views': 0,
            'Replies': 0,
            'Answered': 0,
            'Public': True,
            'Tags': set(['index', 'primarykey', 'table']),
            'LastPostDateTime':  '12/9/2011 11:36:03 PM'}

        item1 = table.new_item(item1_key, item1_range, item1_attrs)
        # make sure the put() succeeds
        try:
            item1.put()
        except c.layer1.ResponseError, e:
            raise Exception("Item put failed: %s" % e)
Esempio n. 7
0
 def setUp(self):
     self.dynamodb = Layer2()
     self.hash_key_name = 'forum_name'
     self.hash_key_proto_value = ''
     self.range_key_name = 'subject'
     self.range_key_proto_value = ''
Esempio n. 8
0
 def setUp(self):
     self.layer2 = Layer2('access_key', 'secret_key')
     self.api = Mock()
     self.layer2.layer1 = self.api
Esempio n. 9
0
 def setUp(self):
     self.layer2 = Layer2('access_key', 'secret_key')
     self.table = Table(self.layer2, DESCRIBE_TABLE_1)
     self.table2 = Table(self.layer2, DESCRIBE_TABLE_2)