Exemplo n.º 1
0
    def test_get_with_unprocessed_keys(self):
        _lv.batch_put_item(self.connection, "Aaa", [{"h": unicode(i), "xs": "x" * 300000} for i in range(100)])  # 300kB items ensure a single BatchGetItem will return at most 55 items

        r1 = self.connection(_lv.BatchGetItem().table("Aaa").keys({"h": unicode(i)} for i in range(100)))

        self.assertEqual(len(r1.unprocessed_keys["Aaa"]["Keys"]), 45)
        self.assertEqual(len(r1.responses["Aaa"]), 55)
Exemplo n.º 2
0
    def test_get_without_unprocessed_keys(self):
        _lv.batch_put_item(self.connection, "Aaa", [{"h": unicode(i)} for i in range(100)])

        r = self.connection(_lv.BatchGetItem().table("Aaa").keys({"h": unicode(i)} for i in range(100)))

        self.assertEqual(r.unprocessed_keys, {})
        self.assertEqual(len(r.responses["Aaa"]), 100)
Exemplo n.º 3
0
def global_setup():
    connection = _lv.Connection("us-west-2", _lv.EnvironmentCredentials())

    table1 = "LowVoltage.Tests.Doc.1"
    table2 = "LowVoltage.Tests.Doc.2"

    try:
        connection(_lv.DescribeTable(table1))
    except _lv.ResourceNotFoundException:
        connection(
            _lv.CreateTable(table)
                .hash_key("h", _lv.NUMBER).provisioned_throughput(1, 1)
                .global_secondary_index("gsi").hash_key("gh", _lv.NUMBER).range_key("gr", _lv.NUMBER).provisioned_throughput(1, 1).project_all()
        )

    try:
        connection(_lv.DescribeTable(table2))
    except _lv.ResourceNotFoundException:
        connection(
            _lv.CreateTable(table2)
                .hash_key("h", _lv.NUMBER).range_key("r1", _lv.NUMBER).provisioned_throughput(1, 1)
                .local_secondary_index("lsi").hash_key("h", _lv.NUMBER).range_key("r2", _lv.NUMBER).project_all()
        )

    _lv.wait_for_table_activation(connection, table1)
    _lv.batch_put_item(
        connection,
        table1,
        [{"h": h, "gh": h * h, "gr": 10 - 2 * h} for h in range(7)],
    )

    _lv.wait_for_table_activation(connection, table1)
    _lv.batch_put_item(
        connection,
        table1,
        [{"h": h, "a": 0} for h in range(7, 10)],
    )

    _lv.wait_for_table_activation(connection, table2)
    _lv.batch_put_item(
        connection,
        table2,
        [{"h": h, "r1": 0, "r2": 0} for h in range(10)],
    )

    _lv.batch_put_item(
        connection,
        table2,
        [{"h": 42, "r1": r1, "r2": 10 - r1} for r1 in range(6)],
    )

    _lv.batch_put_item(
        connection,
        table2,
        [{"h": 42, "r1": r1} for r1 in range(6, 10)],
    )

    return connection, table1, table2
Exemplo n.º 4
0
    def test_get_without_unprocessed_keys(self):
        _lv.batch_put_item(self.connection, "Aaa", [{
            "h": str(i)
        } for i in range(100)])

        r = self.connection(_lv.BatchGetItem().table("Aaa").keys(
            {"h": str(i)} for i in range(100)))

        self.assertEqual(r.unprocessed_keys, {})
        self.assertEqual(len(r.responses["Aaa"]), 100)
Exemplo n.º 5
0
    def test_get_with_unprocessed_keys(self):
        _lv.batch_put_item(
            self.connection, "Aaa", [{
                "h": str(i),
                "xs": "x" * 300000
            } for i in range(100)]
        )  # 300kB items ensure a single BatchGetItem will return at most 55 items

        r1 = self.connection(_lv.BatchGetItem().table("Aaa").keys(
            {"h": str(i)} for i in range(100)))

        self.assertEqual(len(r1.unprocessed_keys["Aaa"]["Keys"]), 45)
        self.assertEqual(len(r1.responses["Aaa"]), 55)
 def setUp(self):
     super(IterateBatchGetItemLocalIntegTests, self).setUp()
     _lv.batch_put_item(self.connection, "Aaa", [{"h": self.key(i), "xs": "x" * 300000} for i in range(250)])  # 300kB items ensure a single BatchGetItem will return at most 55 items
Exemplo n.º 7
0
 def setUp(self):
     super(BatchDeleteItemLocalIntegTests, self).setUp()
     _lv.batch_put_item(self.connection, "Aaa", [{
         "h": self.key(i)
     } for i in range(100)])
Exemplo n.º 8
0
 def test(self):
     _lv.batch_put_item(self.connection, "Aaa", [{"h": self.key(i)} for i in range(100)])
     self.assertEqual(len(list(_lv.iterate_scan(self.connection, _lv.Scan("Aaa")))), 100)
Exemplo n.º 9
0
 def setUp(self):
     super(IterateBatchGetItemLocalIntegTests, self).setUp()
     _lv.batch_put_item(self.connection, "Aaa", [{"h": self.key(i), "xs": "x" * 300000} for i in range(250)])  # 300kB items ensure a single BatchGetItem will return at most 55 items
Exemplo n.º 10
0
 def test(self):
     _lv.batch_put_item(self.connection, "Aaa", [{"h": self.key(i)} for i in range(100)])
     self.assertEqual(len(list(_lv.iterate_scan(self.connection, _lv.Scan("Aaa")))), 100)
Exemplo n.º 11
0
def global_setup():
    connection = _lv.Connection("us-west-2", _lv.EnvironmentCredentials())

    table1 = "LowVoltage.Tests.Doc.1"
    table2 = "LowVoltage.Tests.Doc.2"

    try:
        connection(_lv.DescribeTable(table1))
    except _lv.ResourceNotFoundException:
        connection(
            _lv.CreateTable(table).hash_key(
                "h", _lv.NUMBER).provisioned_throughput(
                    1, 1).global_secondary_index("gsi").hash_key(
                        "gh", _lv.NUMBER).range_key(
                            "gr", _lv.NUMBER).provisioned_throughput(
                                1, 1).project_all())

    try:
        connection(_lv.DescribeTable(table2))
    except _lv.ResourceNotFoundException:
        connection(
            _lv.CreateTable(table2).hash_key("h", _lv.NUMBER).range_key(
                "r1", _lv.NUMBER).provisioned_throughput(
                    1, 1).local_secondary_index("lsi").hash_key(
                        "h", _lv.NUMBER).range_key("r2",
                                                   _lv.NUMBER).project_all())

    _lv.wait_for_table_activation(connection, table1)
    _lv.batch_put_item(
        connection,
        table1,
        [{
            "h": h,
            "gh": h * h,
            "gr": 10 - 2 * h
        } for h in range(7)],
    )

    _lv.wait_for_table_activation(connection, table1)
    _lv.batch_put_item(
        connection,
        table1,
        [{
            "h": h,
            "a": 0
        } for h in range(7, 10)],
    )

    _lv.wait_for_table_activation(connection, table2)
    _lv.batch_put_item(
        connection,
        table2,
        [{
            "h": h,
            "r1": 0,
            "r2": 0
        } for h in range(10)],
    )

    _lv.batch_put_item(
        connection,
        table2,
        [{
            "h": 42,
            "r1": r1,
            "r2": 10 - r1
        } for r1 in range(6)],
    )

    _lv.batch_put_item(
        connection,
        table2,
        [{
            "h": 42,
            "r1": r1
        } for r1 in range(6, 10)],
    )

    return connection, table1, table2
Exemplo n.º 12
0
 def setUp(self):
     super(BatchDeleteItemLocalIntegTests, self).setUp()
     _lv.batch_put_item(self.connection, "Aaa", [{"h": self.key(i)} for i in range(100)])