| 67 | ) |
| 68 | |
| 69 | def test_simple_nesting(self): |
| 70 | sq1 = SQ(foo="bar") |
| 71 | sq2 = SQ(foo="bar") |
| 72 | bigger_sq = SQ(sq1 & sq2) |
| 73 | self.assertEqual( |
| 74 | repr(bigger_sq), "<SQ: AND (foo__content=bar AND foo__content=bar)>" |
| 75 | ) |
| 76 | |
| 77 | another_bigger_sq = SQ(sq1 | sq2) |
| 78 | self.assertEqual( |
| 79 | repr(another_bigger_sq), "<SQ: AND (foo__content=bar OR foo__content=bar)>" |
| 80 | ) |
| 81 | |
| 82 | one_more_bigger_sq = SQ(sq1 & ~sq2) |
| 83 | self.assertEqual( |
| 84 | repr(one_more_bigger_sq), |
| 85 | "<SQ: AND (foo__content=bar AND NOT (foo__content=bar))>", |
| 86 | ) |
| 87 | |
| 88 | mega_sq = SQ(bigger_sq & SQ(another_bigger_sq | ~one_more_bigger_sq)) |
| 89 | self.assertEqual( |
| 90 | repr(mega_sq), |
| 91 | "<SQ: AND ((foo__content=bar AND foo__content=bar) AND ((foo__content=bar OR foo__content=bar) OR NOT ((foo__content=bar AND NOT (foo__content=bar)))))>", |
| 92 | ) |
| 93 | |
| 94 | |
| 95 | class BaseSearchQueryTestCase(TestCase): |