def test_delete_table(self):
        self.storage_mocker.StubOutWithMock(storage, 'delete_table')
        self.storage_mocker.StubOutWithMock(storage, 'describe_table')
        storage.delete_table(IgnoreArg(), 'test_table')

        storage.describe_table(IgnoreArg(), 'test_table').AndReturn(
            models.TableMeta(
                models.TableSchema(
                    {
                        'city1': models.ATTRIBUTE_TYPE_STRING,
                        'id': models.ATTRIBUTE_TYPE_STRING,
                        'name': models.ATTRIBUTE_TYPE_STRING
                    },
                    ['id', 'name'],
                    {'index_name': models.IndexDefinition('city1')}
                ),
                models.TableMeta.TABLE_STATUS_ACTIVE
            )
        )

        self.storage_mocker.ReplayAll()

        table = Table('test_table', connection=self.DYNAMODB_CON)

        self.assertTrue(table.delete())

        self.storage_mocker.VerifyAll()
Example #2
0
    def test_delete_table(self):
        self.storage_mocker.StubOutWithMock(storage, 'delete_table')
        self.storage_mocker.StubOutWithMock(storage, 'describe_table')
        storage.delete_table(mox.IgnoreArg(), 'test_table')

        storage.describe_table(mox.IgnoreArg(), 'test_table').AndReturn(
            models.TableMeta(
                '00000000-0000-0000-0000-000000000000',
                models.TableSchema(
                    {
                        'city1': models.AttributeType('S'),
                        'id': models.AttributeType('S'),
                        'name': models.AttributeType('S')
                    },
                    ['id', 'name'],
                    {'index_name': models.IndexDefinition('id', 'city1')}
                ),
                models.TableMeta.TABLE_STATUS_ACTIVE,
                None
            )
        )

        self.storage_mocker.ReplayAll()

        table = ddb_table.Table(
            'test_table',
            connection=self.DYNAMODB_CON
        )

        self.assertTrue(table.delete())

        self.storage_mocker.VerifyAll()
    def delete_table(self, req, project_id, table_name):
        utils.check_project_id(req.context, project_id)
        req.context.tenant = project_id

        table_schema = storage.describe_table(req.context, table_name)
        storage.delete_table(req.context, table_name)

        url = req.path_url
        bookmark = req.path_url

        return {
            parser.Props.TABLE_DESCRIPTION: {
                parser.Props.ATTRIBUTE_DEFINITIONS: (
                    parser.Parser.format_attribute_definitions(
                        table_schema.schema.attribute_type_map
                    )
                ),
                parser.Props.CREATION_DATE_TIME: 0,
                parser.Props.ITEM_COUNT: 0,
                parser.Props.KEY_SCHEMA: (
                    parser.Parser.format_key_schema(
                        table_schema.schema.key_attributes
                    )
                ),
                parser.Props.LOCAL_SECONDARY_INDEXES: (
                    parser.Parser.format_local_secondary_indexes(
                        table_schema.schema.key_attributes[0],
                        table_schema.schema.index_def_map
                    )
                ),
                parser.Props.TABLE_NAME: table_name,

                parser.Props.TABLE_STATUS: (
                    parser.Values.TABLE_STATUS_ACTIVE),
                parser.Props.TABLE_SIZE_BYTES: 0,

                parser.Props.LINKS: [
                    {
                        parser.Props.HREF: url,
                        parser.Props.REL: parser.Values.SELF
                    },
                    {
                        parser.Props.HREF: bookmark,
                        parser.Props.REL: parser.Values.BOOKMARK
                    }
                ]
            }
        }
Example #4
0
    def __call__(self):

        table_name = self.action_params.get(parser.Props.TABLE_NAME, None)

        try:
            table_meta = storage.describe_table(self.context, table_name)

            storage.delete_table(self.context, table_name)

            # TODO(isviridov): fill ITEM_COUNT, TABLE_SIZE_BYTES,
            # CREATION_DATE_TIME with real data
            return {
                parser.Props.TABLE_DESCRIPTION: {
                    parser.Props.ATTRIBUTE_DEFINITIONS: (
                        parser.Parser.format_attribute_definitions(
                            table_meta.schema.attribute_type_map
                        )
                    ),
                    parser.Props.CREATION_DATE_TIME: 0,
                    parser.Props.ITEM_COUNT: 0,
                    parser.Props.KEY_SCHEMA: (
                        parser.Parser.format_key_schema(
                            table_meta.schema.key_attributes
                        )
                    ),
                    parser.Props.LOCAL_SECONDARY_INDEXES: (
                        parser.Parser.format_local_secondary_indexes(
                            table_meta.schema.key_attributes[0],
                            table_meta.schema.index_def_map
                        )
                    ),
                    parser.Props.PROVISIONED_THROUGHPUT: (
                        parser.Values.PROVISIONED_THROUGHPUT_DUMMY
                    ),
                    parser.Props.TABLE_NAME: table_name,
                    parser.Props.TABLE_STATUS: (
                        parser.Parser.format_table_status(table_meta.status)
                    ),
                    parser.Props.TABLE_SIZE_BYTES: 0
                }
            }
        except exception.AWSErrorResponseException as e:
            raise e
        except Exception:
            raise exception.AWSErrorResponseException()
Example #5
0
    def __call__(self):

        table_name = self.action_params.get(Props.TABLE_NAME, None)

        try:
            table_meta = storage.describe_table(self.context, table_name)

            storage.delete_table(self.context, table_name)

            # TODO (isviridov): fill ITEM_COUNT, TABLE_SIZE_BYTES,
            # CREATION_DATE_TIME with real data
            return {
                Props.TABLE_DESCRIPTION: {
                    Props.ATTRIBUTE_DEFINITIONS: (
                        Parser.format_attribute_definitions(
                            table_meta.schema.attribute_type_map
                        )
                    ),
                    Props.CREATION_DATE_TIME: 0,
                    Props.ITEM_COUNT: 0,
                    Props.KEY_SCHEMA: (
                        Parser.format_key_schema(
                            table_meta.schema.key_attributes
                        )
                    ),
                    Props.LOCAL_SECONDARY_INDEXES: (
                        Parser.format_local_secondary_indexes(
                            table_meta.schema.key_attributes[0],
                            table_meta.schema.index_def_map
                        )
                    ),
                    Props.PROVISIONED_THROUGHPUT: (
                        Values.PROVISIONED_THROUGHPUT_DUMMY
                    ),
                    Props.TABLE_NAME: table_name,
                    Props.TABLE_STATUS: Parser.format_table_status(
                        table_meta.status
                    ),
                    Props.TABLE_SIZE_BYTES: 0
                }
            }
        except exception.AWSErrorResponseException as e:
            raise e
        except Exception:
            raise exception.AWSErrorResponseException()
    def delete_table(self, req, project_id, table_name):
        utils.check_project_id(req.context, project_id)
        req.context.tenant = project_id

        table_schema = storage.describe_table(req.context, table_name)
        storage.delete_table(req.context, table_name)

        url = req.path_url
        bookmark = req.path_url

        return {
            parser.Props.TABLE_DESCRIPTION: {
                parser.Props.ATTRIBUTE_DEFINITIONS:
                (parser.Parser.format_attribute_definitions(
                    table_schema.schema.attribute_type_map)),
                parser.Props.CREATION_DATE_TIME:
                0,
                parser.Props.ITEM_COUNT:
                0,
                parser.Props.KEY_SCHEMA: (parser.Parser.format_key_schema(
                    table_schema.schema.key_attributes)),
                parser.Props.LOCAL_SECONDARY_INDEXES:
                (parser.Parser.format_local_secondary_indexes(
                    table_schema.schema.key_attributes[0],
                    table_schema.schema.index_def_map)),
                parser.Props.TABLE_NAME:
                table_name,
                parser.Props.TABLE_STATUS: (parser.Values.TABLE_STATUS_ACTIVE),
                parser.Props.TABLE_SIZE_BYTES:
                0,
                parser.Props.LINKS: [{
                    parser.Props.HREF: url,
                    parser.Props.REL: parser.Values.SELF
                }, {
                    parser.Props.HREF: bookmark,
                    parser.Props.REL: parser.Values.BOOKMARK
                }]
            }
        }
Example #7
0
    def test_delete_table(self):
        self.storage_mocker.StubOutWithMock(storage, 'delete_table')
        self.storage_mocker.StubOutWithMock(storage, 'describe_table')
        storage.delete_table(IgnoreArg(), 'test_table')

        storage.describe_table(IgnoreArg(), 'test_table').AndReturn(
            models.TableMeta(
                models.TableSchema(
                    {
                        'city1': models.ATTRIBUTE_TYPE_STRING,
                        'id': models.ATTRIBUTE_TYPE_STRING,
                        'name': models.ATTRIBUTE_TYPE_STRING
                    }, ['id', 'name'],
                    {'index_name': models.IndexDefinition('city1')}),
                models.TableMeta.TABLE_STATUS_ACTIVE))

        self.storage_mocker.ReplayAll()

        table = Table('test_table', connection=self.DYNAMODB_CON)

        self.assertTrue(table.delete())

        self.storage_mocker.VerifyAll()
Example #8
0
def delete_table(req, project_id, table_name):
    """The DeleteTable operation deletes a table and all of its items."""

    validation.validate_table_name(table_name)

    table_meta = storage.delete_table(project_id, table_name)

    url = req.path_url
    bookmark = req.path_url

    return {
        parser.Props.TABLE_DESCRIPTION: {
            parser.Props.ATTRIBUTE_DEFINITIONS: (
                parser.Parser.format_attribute_definitions(
                    table_meta.schema.attribute_type_map
                )
            ),
            parser.Props.CREATION_DATE_TIME:
                table_meta.creation_date_time,
            parser.Props.ITEM_COUNT: 0,
            parser.Props.KEY_SCHEMA: (
                parser.Parser.format_key_schema(
                    table_meta.schema.key_attributes
                )
            ),
            parser.Props.LOCAL_SECONDARY_INDEXES: (
                parser.Parser.format_local_secondary_indexes(
                    table_meta.schema.key_attributes[0],
                    table_meta.schema.index_def_map
                )
            ),
            parser.Props.TABLE_ID: str(table_meta.id),
            parser.Props.TABLE_NAME: table_name,

            parser.Props.TABLE_STATUS: (
                parser.Parser.format_table_status(table_meta.status)),
            parser.Props.TABLE_SIZE_BYTES: 0,

            parser.Props.LINKS: [
                {
                    parser.Props.HREF: url,
                    parser.Props.REL: parser.Values.SELF
                },
                {
                    parser.Props.HREF: bookmark,
                    parser.Props.REL: parser.Values.BOOKMARK
                }
            ]
        }
    }
Example #9
0
    def __call__(self):

        table_name = self.action_params.get(Props.TABLE_NAME, None)

        table_schema = storage.describe_table(self.context, table_name)

        storage.delete_table(self.context, table_name)

        #TODO (isviridov): fill ITEM_COUNT, TABLE_SIZE_BYTES,
        # CREATION_DATE_TIME with real data
        return {
            Props.TABLE_DESCRIPTION: {
                Props.ATTRIBUTE_DEFINITIONS: (
                    map(Parser.format_attribute_definition,
                        table_schema.attribute_defs)
                ),
                Props.CREATION_DATE_TIME: 0,
                Props.ITEM_COUNT: 0,
                Props.KEY_SCHEMA: (
                    Parser.format_key_schema(
                        table_schema.key_attributes
                    )
                ),
                Props.LOCAL_SECONDARY_INDEXES: (
                    Parser.format_local_secondary_indexes(
                        table_schema.key_attributes[0],
                        table_schema.index_defs
                    )
                ),
                Props.PROVISIONED_THROUGHPUT: (
                    Values.PROVISIONED_THROUGHPUT_DUMMY
                ),
                Props.TABLE_NAME: table_schema.table_name,
                Props.TABLE_STATUS: Values.TABLE_STATUS_ACTIVE,
                Props.TABLE_SIZE_BYTES: 0
            }
        }
Example #10
0
    def delete_table(self, req, project_id, table_name):
        validation.validate_table_name(table_name)

        table_meta = storage.delete_table(req.context, table_name)

        url = req.path_url
        bookmark = req.path_url

        return {
            parser.Props.TABLE_DESCRIPTION: {
                parser.Props.ATTRIBUTE_DEFINITIONS:
                (parser.Parser.format_attribute_definitions(
                    table_meta.schema.attribute_type_map)),
                parser.Props.CREATION_DATE_TIME:
                table_meta.creation_date_time,
                parser.Props.ITEM_COUNT:
                0,
                parser.Props.KEY_SCHEMA: (parser.Parser.format_key_schema(
                    table_meta.schema.key_attributes)),
                parser.Props.LOCAL_SECONDARY_INDEXES:
                (parser.Parser.format_local_secondary_indexes(
                    table_meta.schema.key_attributes[0],
                    table_meta.schema.index_def_map)),
                parser.Props.TABLE_ID:
                str(table_meta.id),
                parser.Props.TABLE_NAME:
                table_name,
                parser.Props.TABLE_STATUS:
                (parser.Parser.format_table_status(table_meta.status)),
                parser.Props.TABLE_SIZE_BYTES:
                0,
                parser.Props.LINKS: [{
                    parser.Props.HREF: url,
                    parser.Props.REL: parser.Values.SELF
                }, {
                    parser.Props.HREF: bookmark,
                    parser.Props.REL: parser.Values.BOOKMARK
                }]
            }
        }