예제 #1
0
 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'
         })
예제 #2
0
    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'})
예제 #3
0
 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'
         })
예제 #4
0
 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'
     }, {})
예제 #5
0
 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'})
예제 #6
0
 def test_build_attr_list(self):
     a = Attr('MyList[0]')
     self.assert_condition_expression_build(a.eq('foo'), '#n0[0] = :v0',
                                            {'#n0': 'MyList'},
                                            {':v0': 'foo'})
예제 #7
0
 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'})
예제 #8
0
 def test_build_with_is_key_condition_throws_error(self):
     a = Attr('myattr')
     with self.assertRaises(DynamoDBNeedsKeyConditionError):
         self.builder.build_expression(a.eq('foo'), is_key_condition=True)
예제 #9
0
 def test_build_not(self):
     a = Attr('myattr')
     self.assert_condition_expression_build(~a.eq('foo'), '(NOT #n0 = :v0)',
                                            {'#n0': 'myattr'},
                                            {':v0': 'foo'})