@@ -0,0 +1,1534 @@
+from unittest import TestCase%0A%0Afrom django.db.models import Q%0A%0Afrom binder.views import prefix_q_expression%0Afrom binder.permissions.views import is_q_child_equal%0A%0Afrom .testapp.models import Animal%0A%0A%0Aclass TestPrefixQExpression(TestCase):%0A%0A%09def test_simple_prefix(self):%0A%09%09self.assertTrue(is_q_child_equal(%0A%09%09%09prefix_q_expression(Q(foo=1), 'prefix'),%0A%09%09%09Q(prefix__foo=1),%0A%09%09))%0A%0A%09def test_nested_prefix(self):%0A%09%09self.assertTrue(is_q_child_equal(%0A%09%09%09prefix_q_expression(Q(foo=1) & ~Q(bar=2) %7C Q(baz=3), 'prefix'),%0A%09%09%09Q(prefix__foo=1) & ~Q(prefix__bar=2) %7C Q(prefix__baz=3),%0A%09%09))%0A%0A%09def test_prefix_identity(self):%0A%09%09self.assertTrue(is_q_child_equal(%0A%09%09%09prefix_q_expression(Q(pk__in=%5B%5D), 'prefix'),%0A%09%09%09Q(pk__in=%5B%5D),%0A%09%09))%0A%0A%09def test_antiprefix_field(self):%0A%09%09self.assertTrue(is_q_child_equal(%0A%09%09%09prefix_q_expression(Q(name='Apenheul', animals__name='Bokito'), 'zoo', 'animals', Animal),%0A%09%09%09Q(zoo__name='Apenheul', name='Bokito'),%0A%09%09))%0A%0A%09def test_antiprefix_no_field(self):%0A%09%09self.assertTrue(is_q_child_equal(%0A%09%09%09prefix_q_expression(Q(name='Apenheul', animals=1), 'zoo', 'animals', Animal),%0A%09%09%09Q(zoo__name='Apenheul', pk=1),%0A%09%09))%0A%0A%09def test_antiprefix_pk(self):%0A%09%09self.assertTrue(is_q_child_equal(%0A%09%09%09prefix_q_expression(Q(name='Apenheul', animals__pk=1), 'zoo', 'animals', Animal),%0A%09%09%09Q(zoo__name='Apenheul', pk=1),%0A%09%09))%0A%0A%09def test_antiprefix_modifier(self):%0A%09%09self.assertTrue(is_q_child_equal(%0A%09%09%09prefix_q_expression(Q(name='Apenheul', animals__in=%5B1, 2, 3%5D), 'zoo', 'animals', Animal),%0A%09%09%09Q(zoo__name='Apenheul', pk__in=%5B1, 2, 3%5D),%0A%09%09))%0A

Add tests for prefix Q expression