本文整理汇总了Python中boto3.dynamodb.conditions.Attr类的典型用法代码示例。如果您正苦于以下问题:Python Attr类的具体用法?Python Attr怎么用?Python Attr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Attr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reset
def test_reset(self):
a = Attr("myattr")
self.assert_condition_expression_build(a.eq("foo"), "#n0 = :v0", {"#n0": "myattr"}, {":v0": "foo"})
self.assert_condition_expression_build(a.eq("foo"), "#n1 = :v1", {"#n1": "myattr"}, {":v1": "foo"})
self.builder.reset()
self.assert_condition_expression_build(a.eq("foo"), "#n0 = :v0", {"#n0": "myattr"}, {":v0": "foo"})
示例2: test_build_or
def test_build_or(self):
a = Attr("myattr")
a2 = Attr("myattr2")
self.assert_condition_expression_build(
a.eq("foo") | a2.eq("bar"),
"(#n0 = :v0 OR #n1 = :v1)",
{"#n0": "myattr", "#n1": "myattr2"},
{":v0": "foo", ":v1": "bar"},
)
示例3: test_reset
def test_reset(self):
a = Attr('myattr')
self.assert_condition_expression_build(
a.eq('foo'), '#n0 = :v0', {'#n0': 'myattr'}, {':v0': 'foo'})
self.assert_condition_expression_build(
a.eq('foo'), '#n1 = :v1', {'#n1': 'myattr'}, {':v1': 'foo'})
self.builder.reset()
self.assert_condition_expression_build(
a.eq('foo'), '#n0 = :v0', {'#n0': 'myattr'}, {':v0': 'foo'})
示例4: TestA
class TestA(TestK):
def setUp(self):
self.attr = Attr("mykey")
self.attr2 = Attr("myotherkey")
self.value = "foo"
self.value2 = "foo2"
def test_ne(self):
self.assertEqual(self.attr.ne(self.value), NotEquals(self.attr, self.value))
def test_is_in(self):
self.assertEqual(self.attr.is_in([self.value]), In(self.attr, [self.value]))
def test_exists(self):
self.assertEqual(self.attr.exists(), AttributeExists(self.attr))
def test_not_exists(self):
self.assertEqual(self.attr.not_exists(), AttributeNotExists(self.attr))
def test_contains(self):
self.assertEqual(self.attr.contains(self.value), Contains(self.attr, self.value))
def test_size(self):
self.assertEqual(self.attr.size(), Size(self.attr))
def test_attribute_type(self):
self.assertEqual(self.attr.attribute_type(self.value), AttributeType(self.attr, self.value))
示例5: test_build_double_nested_and_or
def test_build_double_nested_and_or(self):
a = Attr('myattr')
a2 = Attr('myattr2')
self.assert_condition_expression_build(
(a.eq('foo') & a2.eq('foo2')) | (a.eq('bar') & a2.eq('bar2')),
'((#n0 = :v0 AND #n1 = :v1) OR (#n2 = :v2 AND #n3 = :v3))',
{'#n0': 'myattr', '#n1': 'myattr2', '#n2': 'myattr',
'#n3': 'myattr2'},
{':v0': 'foo', ':v1': 'foo2', ':v2': 'bar', ':v3': 'bar2'})
示例6: test_build_double_nested_and_or
def test_build_double_nested_and_or(self):
a = Attr("myattr")
a2 = Attr("myattr2")
self.assert_condition_expression_build(
(a.eq("foo") & a2.eq("foo2")) | (a.eq("bar") & a2.eq("bar2")),
"((#n0 = :v0 AND #n1 = :v1) OR (#n2 = :v2 AND #n3 = :v3))",
{"#n0": "myattr", "#n1": "myattr2", "#n2": "myattr", "#n3": "myattr2"},
{":v0": "foo", ":v1": "foo2", ":v2": "bar", ":v3": "bar2"},
)
示例7: test_build_size
def test_build_size(self):
a = Attr('myattr')
self.assert_condition_expression_build(
a.size(), 'size(#n0)', {'#n0': 'myattr'}, {})
示例8: test_build_contains
def test_build_contains(self):
a = Attr('myattr')
self.assert_condition_expression_build(
a.contains('foo'), 'contains(#n0, :v0)',
{'#n0': 'myattr'}, {':v0': 'foo'})
示例9: test_build_nested_attr_map_list
def test_build_nested_attr_map_list(self):
a = Attr('MyMap.MyList[2].MyElement')
self.assert_condition_expression_build(
a.eq('foo'), '#n0.#n1[2].#n2 = :v0',
{'#n0': 'MyMap', '#n1': 'MyList', '#n2': 'MyElement'},
{':v0': 'foo'})
示例10: test_build_attribute_with_attr_value
def test_build_attribute_with_attr_value(self):
a = Attr('myattr')
value = Attr('myreference')
self.assert_condition_expression_build(
a.eq(value), '#n0 = #n1',
{'#n0': 'myattr', '#n1': 'myreference'}, {})
示例11: test_build_attr_map
def test_build_attr_map(self):
a = Attr('MyMap.MyKey')
self.assert_condition_expression_build(
a.eq('foo'), '#n0.#n1 = :v0', {'#n0': 'MyMap', '#n1': 'MyKey'},
{':v0': 'foo'})
示例12: test_build_expression_lte
def test_build_expression_lte(self):
a1 = Attr('myattr')
self.assert_condition_expression_build(
a1.lte('foo'), '#n0 <= :v0', {'#n0': 'myattr'}, {':v0': 'foo'})
示例13: test_build_or
def test_build_or(self):
a = Attr('myattr')
a2 = Attr('myattr2')
self.assert_condition_expression_build(
a.eq('foo') | a2.eq('bar'), '(#n0 = :v0 OR #n1 = :v1)',
{'#n0': 'myattr', '#n1': 'myattr2'}, {':v0': 'foo', ':v1': 'bar'})
示例14: setUp
def setUp(self):
self.attr = Attr('mykey')
self.attr2 = Attr('myotherkey')
self.value = 'foo'
self.value2 = 'foo2'
示例15: test_build_attr_map
def test_build_attr_map(self):
a = Attr("MyMap.MyKey")
self.assert_condition_expression_build(
a.eq("foo"), "#n0.#n1 = :v0", {"#n0": "MyMap", "#n1": "MyKey"}, {":v0": "foo"}
)