diff --git a/tests/unit/dynamodb/test_conditions.py b/tests/unit/dynamodb/test_conditions.py index 2e504e7a77..736cbf6c36 100644 --- a/tests/unit/dynamodb/test_conditions.py +++ b/tests/unit/dynamodb/test_conditions.py @@ -326,6 +326,10 @@ def test_lte(self): }, ) + def test_lte_repr(self): + actual_repr = str(LessThanEquals(self.value, self.value2)) + assert actual_repr == 'mykey <= foo' + def test_gt(self): self.build_and_assert_expression( GreaterThan(self.value, self.value2), @@ -336,6 +340,10 @@ def test_gt(self): }, ) + def test_gt_repr(self): + actual_repr = str(GreaterThan(self.value, self.value2)) + assert actual_repr == 'mykey > foo' + def test_gte(self): self.build_and_assert_expression( GreaterThanEquals(self.value, self.value2), @@ -346,6 +354,10 @@ def test_gte(self): }, ) + def test_gte_repr(self): + actual_repr = str(GreaterThanEquals(self.value, self.value2)) + assert actual_repr == 'mykey >= foo' + def test_in(self): cond = In(self.value, (self.value2)) self.build_and_assert_expression( @@ -358,6 +370,10 @@ def test_in(self): ) assert cond.has_grouped_values + def test_in_repr(self): + actual_repr = str(In(self.value, self.value2)) + assert actual_repr == 'mykey IN foo' + def test_bet(self): self.build_and_assert_expression( Between(self.value, self.value2, 'foo2'), @@ -368,6 +384,10 @@ def test_bet(self): }, ) + def test_bet_repr(self): + actual_repr = str(Between(self.value, self.value2, 'foo2')) + assert actual_repr == 'mykey BETWEEN foo AND foo2' + def test_beg(self): self.build_and_assert_expression( BeginsWith(self.value, self.value2), @@ -378,6 +398,10 @@ def test_beg(self): }, ) + def test_beg_repr(self): + actual_repr = str(BeginsWith(self.value, self.value2)) + assert actual_repr == 'begins_with(mykey, foo)' + def test_cont(self): self.build_and_assert_expression( Contains(self.value, self.value2), @@ -388,6 +412,10 @@ def test_cont(self): }, ) + def test_cont_repr(self): + actual_repr = str(Contains(self.value, self.value2)) + assert actual_repr == 'contains(mykey, foo)' + def test_ae(self): self.build_and_assert_expression( AttributeExists(self.value), @@ -398,6 +426,10 @@ def test_ae(self): }, ) + def test_ae_repr(self): + actual_repr = str(AttributeExists(self.value)) + assert actual_repr == 'attribute_exists(mykey)' + def test_ane(self): self.build_and_assert_expression( AttributeNotExists(self.value), @@ -408,6 +440,10 @@ def test_ane(self): }, ) + def test_ane_repr(self): + actual_repr = str(AttributeNotExists(self.value)) + assert actual_repr == 'attribute_not_exists(mykey)' + def test_size(self): self.build_and_assert_expression( Size(self.value), @@ -418,6 +454,10 @@ def test_size(self): }, ) + def test_size_repr(self): + actual_repr = str(Size(self.value)) + assert actual_repr == 'size(mykey)' + def test_size_can_use_attr_methods(self): size = Size(self.value) self.build_and_assert_expression( @@ -429,6 +469,10 @@ def test_size_can_use_attr_methods(self): }, ) + def test_size_eq_repr(self): + actual_repr = str(Size(self.value).eq(self.value2)) + assert actual_repr == 'size(mykey) = foo' + def test_size_can_use_and(self): size = Size(self.value) ae = AttributeExists(self.value) @@ -441,6 +485,10 @@ def test_size_can_use_and(self): }, ) + def test_size_and_ae_repr(self): + actual_repr = str(Size(self.value) & AttributeExists(self.value)) + assert actual_repr == '(size(mykey) AND attribute_exists(mykey))' + def test_attribute_type(self): self.build_and_assert_expression( AttributeType(self.value, self.value2), @@ -451,6 +499,10 @@ def test_attribute_type(self): }, ) + def test_attribute_type_repr(self): + actual_repr = str(AttributeType(self.value, self.value2)) + assert actual_repr == 'attribute_type(mykey, foo)' + def test_and(self): cond1 = Equals(self.value, self.value2) cond2 = Equals(self.value, self.value2) @@ -464,6 +516,12 @@ def test_and(self): }, ) + def test_and_repr(self): + cond1 = Equals(self.value, self.value2) + cond2 = Equals(self.value, self.value2) + actual_repr = str(And(cond1, cond2)) + assert actual_repr == '(mykey = foo AND mykey = foo)' + def test_or(self): cond1 = Equals(self.value, self.value2) cond2 = Equals(self.value, self.value2) @@ -477,6 +535,12 @@ def test_or(self): }, ) + def test_or_repr(self): + cond1 = Equals(self.value, self.value2) + cond2 = Equals(self.value, self.value2) + actual_repr = str(Or(cond1, cond2)) + assert actual_repr == '(mykey = foo OR mykey = foo)' + def test_not(self): cond = Equals(self.value, self.value2) not_cond = Not(cond) @@ -489,6 +553,11 @@ def test_not(self): }, ) + def test_not_repr(self): + cond = Equals(self.value, self.value2) + actual_repr = str(Not(cond)) + assert actual_repr == '(NOT mykey = foo)' + class TestConditionExpressionBuilder(unittest.TestCase): def setUp(self):