Skip to content

Commit 3b00c06

Browse files
committed
Update test_conditions.py
1 parent b2cb40f commit 3b00c06

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

tests/unit/dynamodb/test_conditions.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ def test_lte(self):
326326
},
327327
)
328328

329+
def test_lte_repr(self):
330+
actual_repr = str(LessThanEquals(self.value, self.value2))
331+
assert actual_repr == 'mykey <= foo'
332+
329333
def test_gt(self):
330334
self.build_and_assert_expression(
331335
GreaterThan(self.value, self.value2),
@@ -336,6 +340,10 @@ def test_gt(self):
336340
},
337341
)
338342

343+
def test_gt_repr(self):
344+
actual_repr = str(GreaterThan(self.value, self.value2))
345+
assert actual_repr == 'mykey > foo'
346+
339347
def test_gte(self):
340348
self.build_and_assert_expression(
341349
GreaterThanEquals(self.value, self.value2),
@@ -346,6 +354,10 @@ def test_gte(self):
346354
},
347355
)
348356

357+
def test_gte_repr(self):
358+
actual_repr = str(GreaterThanEquals(self.value, self.value2))
359+
assert actual_repr == 'mykey >= foo'
360+
349361
def test_in(self):
350362
cond = In(self.value, (self.value2))
351363
self.build_and_assert_expression(
@@ -358,6 +370,10 @@ def test_in(self):
358370
)
359371
assert cond.has_grouped_values
360372

373+
def test_in_repr(self):
374+
actual_repr = str(In(self.value, self.value2))
375+
assert actual_repr == 'mykey IN foo'
376+
361377
def test_bet(self):
362378
self.build_and_assert_expression(
363379
Between(self.value, self.value2, 'foo2'),
@@ -368,6 +384,10 @@ def test_bet(self):
368384
},
369385
)
370386

387+
def test_bet_repr(self):
388+
actual_repr = str(Between(self.value, self.value2, 'foo2'))
389+
assert actual_repr == 'mykey BETWEEN foo AND foo2'
390+
371391
def test_beg(self):
372392
self.build_and_assert_expression(
373393
BeginsWith(self.value, self.value2),
@@ -378,6 +398,10 @@ def test_beg(self):
378398
},
379399
)
380400

401+
def test_beg_repr(self):
402+
actual_repr = str(BeginsWith(self.value, self.value2))
403+
assert actual_repr == 'begins_with(mykey, foo)'
404+
381405
def test_cont(self):
382406
self.build_and_assert_expression(
383407
Contains(self.value, self.value2),
@@ -388,6 +412,10 @@ def test_cont(self):
388412
},
389413
)
390414

415+
def test_cont_repr(self):
416+
actual_repr = str(Contains(self.value, self.value2))
417+
assert actual_repr == 'contains(mykey, foo)'
418+
391419
def test_ae(self):
392420
self.build_and_assert_expression(
393421
AttributeExists(self.value),
@@ -398,6 +426,10 @@ def test_ae(self):
398426
},
399427
)
400428

429+
def test_ae_repr(self):
430+
actual_repr = str(AttributeExists(self.value))
431+
assert actual_repr == 'attribute_exists(mykey)'
432+
401433
def test_ane(self):
402434
self.build_and_assert_expression(
403435
AttributeNotExists(self.value),
@@ -408,6 +440,10 @@ def test_ane(self):
408440
},
409441
)
410442

443+
def test_ane_repr(self):
444+
actual_repr = str(AttributeNotExists(self.value))
445+
assert actual_repr == 'attribute_not_exists(mykey)'
446+
411447
def test_size(self):
412448
self.build_and_assert_expression(
413449
Size(self.value),
@@ -418,6 +454,10 @@ def test_size(self):
418454
},
419455
)
420456

457+
def test_size_repr(self):
458+
actual_repr = str(Size(self.value))
459+
assert actual_repr == 'size(mykey)'
460+
421461
def test_size_can_use_attr_methods(self):
422462
size = Size(self.value)
423463
self.build_and_assert_expression(
@@ -429,6 +469,10 @@ def test_size_can_use_attr_methods(self):
429469
},
430470
)
431471

472+
def test_size_eq_repr(self):
473+
actual_repr = str(Size(self.value).eq(self.value2))
474+
assert actual_repr == 'size(mykey) = foo'
475+
432476
def test_size_can_use_and(self):
433477
size = Size(self.value)
434478
ae = AttributeExists(self.value)
@@ -441,6 +485,10 @@ def test_size_can_use_and(self):
441485
},
442486
)
443487

488+
def test_size_and_ae_repr(self):
489+
actual_repr = str(Size(self.value) & AttributeExists(self.value))
490+
assert actual_repr == '(size(mykey) AND attribute_exists(mykey))'
491+
444492
def test_attribute_type(self):
445493
self.build_and_assert_expression(
446494
AttributeType(self.value, self.value2),
@@ -451,6 +499,10 @@ def test_attribute_type(self):
451499
},
452500
)
453501

502+
def test_attribute_type_repr(self):
503+
actual_repr = str(AttributeType(self.value, self.value2))
504+
assert actual_repr == 'attribute_type(mykey, foo)'
505+
454506
def test_and(self):
455507
cond1 = Equals(self.value, self.value2)
456508
cond2 = Equals(self.value, self.value2)
@@ -464,6 +516,12 @@ def test_and(self):
464516
},
465517
)
466518

519+
def test_and_repr(self):
520+
cond1 = Equals(self.value, self.value2)
521+
cond2 = Equals(self.value, self.value2)
522+
actual_repr = str(And(cond1, cond2))
523+
assert actual_repr == '(mykey = foo AND mykey = foo)'
524+
467525
def test_or(self):
468526
cond1 = Equals(self.value, self.value2)
469527
cond2 = Equals(self.value, self.value2)
@@ -477,6 +535,12 @@ def test_or(self):
477535
},
478536
)
479537

538+
def test_or_repr(self):
539+
cond1 = Equals(self.value, self.value2)
540+
cond2 = Equals(self.value, self.value2)
541+
actual_repr = str(Or(cond1, cond2))
542+
assert actual_repr == '(mykey = foo OR mykey = foo)'
543+
480544
def test_not(self):
481545
cond = Equals(self.value, self.value2)
482546
not_cond = Not(cond)
@@ -489,6 +553,11 @@ def test_not(self):
489553
},
490554
)
491555

556+
def test_not_repr(self):
557+
cond = Equals(self.value, self.value2)
558+
actual_repr = str(Not(cond))
559+
assert actual_repr == '(NOT mykey = foo)'
560+
492561

493562
class TestConditionExpressionBuilder(unittest.TestCase):
494563
def setUp(self):

0 commit comments

Comments
 (0)