Skip to content

Commit

Permalink
Update test_conditions.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rajveerappan committed Aug 5, 2024
1 parent b991f52 commit dd9e4fd
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/unit/dynamodb/test_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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(
Expand All @@ -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'),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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(
Expand All @@ -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)
Expand All @@ -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),
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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):
Expand Down

0 comments on commit dd9e4fd

Please sign in to comment.