コード例 #1
0
    def test_char_field_exact(self):
        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'exact', "test"), AND)
        self.assertEquals(where.as_sql(), ("(cn=test)", []))

        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'exact', "(test)"),
                  AND)
        self.assertEquals(where.as_sql(), ("(cn=\\28test\\29)", []))
コード例 #2
0
    def test_list_field_contains(self):
        where = WhereNode()
        where.add((Constraint("memberUid", "memberUid",
                              ListField()), 'contains', 'foouser'), AND)
        self.assertEquals(where.as_sql(), ("(memberUid=foouser)", []))

        where = WhereNode()
        where.add((Constraint("memberUid", "memberUid",
                              ListField()), 'contains', '(foouser)'), AND)
        self.assertEquals(where.as_sql(), ("(memberUid=\\28foouser\\29)", []))
コード例 #3
0
    def test_char_field_startswith(self):
        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'startswith', "test"),
                  AND)
        self.assertEquals(where.as_sql(), ("(cn=test*)", []))

        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'startswith', "te*st"),
                  AND)
        self.assertEquals(where.as_sql(), ("(cn=te\\2ast*)", []))
コード例 #4
0
    def test_char_field_contains(self):
        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'contains', "test"),
                  AND)
        self.assertEquals(where.as_sql(), ("(cn=*test*)", []))

        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'contains', "te*st"),
                  AND)
        self.assertEquals(where.as_sql(), ("(cn=*te\\2ast*)", []))
コード例 #5
0
    def test_char_field_in(self):
        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'in', ["foo", "bar"]),
                  AND)
        self.assertEquals(where.as_sql(), ("(|(cn=foo)(cn=bar))", []))

        where = WhereNode()
        where.add(
            (Constraint("cn", "cn", CharField()), 'in', ["(foo)", "(bar)"]),
            AND)
        self.assertEquals(where.as_sql(),
                          ("(|(cn=\\28foo\\29)(cn=\\28bar\\29))", []))
コード例 #6
0
ファイル: tests.py プロジェクト: Ozzee/password-safe-django
    def test_char_field_contains(self):
        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'contains', "test"), AND)
        self.assertEquals(where.as_sql(), ("(cn=*test*)", []))

        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'contains', "te*st"), AND)
        self.assertEquals(where.as_sql(), ("(cn=*te\\2ast*)", []))
コード例 #7
0
ファイル: tests.py プロジェクト: Ozzee/password-safe-django
    def test_char_field_startswith(self):
        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'startswith', "test"), AND)
        self.assertEquals(where.as_sql(), ("(cn=test*)", []))

        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'startswith', "te*st"), AND)
        self.assertEquals(where.as_sql(), ("(cn=te\\2ast*)", []))
コード例 #8
0
ファイル: tests.py プロジェクト: Ozzee/password-safe-django
    def test_char_field_in(self):
        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'in', ["foo", "bar"]), AND)
        self.assertEquals(where.as_sql(), ("(|(cn=foo)(cn=bar))", []))

        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'in', ["(foo)", "(bar)"]), AND)
        self.assertEquals(where.as_sql(), ("(|(cn=\\28foo\\29)(cn=\\28bar\\29))", []))
コード例 #9
0
ファイル: tests.py プロジェクト: Ozzee/password-safe-django
    def test_char_field_exact(self):
        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'exact', "test"), AND)
        self.assertEquals(where.as_sql(), ("(cn=test)", []))

        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'exact', "(test)"), AND)
        self.assertEquals(where.as_sql(), ("(cn=\\28test\\29)", []))
コード例 #10
0
ファイル: tests.py プロジェクト: Ozzee/password-safe-django
    def test_list_field_contains(self):
        where = WhereNode()
        where.add((Constraint("memberUid", "memberUid", ListField()), 'contains', 'foouser'), AND)
        self.assertEquals(where.as_sql(), ("(memberUid=foouser)", []))

        where = WhereNode()
        where.add((Constraint("memberUid", "memberUid", ListField()), 'contains', '(foouser)'), AND)
        self.assertEquals(where.as_sql(), ("(memberUid=\\28foouser\\29)", []))
コード例 #11
0
    def test_integer_field(self):
        where = WhereNode()
        where.add((Constraint("uid", "uid", IntegerField()), 'exact', 1), AND)
        self.assertEquals(where_as_ldap(where), ("(uid=1)", []))

        where = WhereNode()
        where.add((Constraint("uid", "uid", IntegerField()), 'gte', 1), AND)
        self.assertEquals(where_as_ldap(where), ("(uid>=1)", []))

        where = WhereNode()
        where.add((Constraint("uid", "uid", IntegerField()), 'lte', 1), AND)
        self.assertEquals(where_as_ldap(where), ("(uid<=1)", []))
コード例 #12
0
    def test_char_field_endswith(self):
        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'endswith', "test"),
                  AND)
        self.assertEquals(where_as_ldap(where), ("(cn=*test)", []))

        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'endswith', "te*st"),
                  AND)
        self.assertEquals(where_as_ldap(where), ("(cn=*te\\2ast)", []))
コード例 #13
0
 def test_or(self):
     where = WhereNode()
     where.add((Constraint("cn", "cn", CharField()), 'exact', "foo"), AND)
     where.add((Constraint("givenName", "givenName",
                           CharField()), 'exact', "bar"), OR)
     self.assertEquals(where_as_ldap(where),
                       ("(|(cn=foo)(givenName=bar))", []))
コード例 #14
0
    def test_char_field_endswith(self):
        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'endswith', "test"), AND)
        self.assertEquals(where_as_ldap(where), ("(cn=*test)", []))

        where = WhereNode()
        where.add((Constraint("cn", "cn", CharField()), 'endswith', "te*st"), AND)
        self.assertEquals(where_as_ldap(where), ("(cn=*te\\2ast)", []))
コード例 #15
0
 def test_or(self):
     where = WhereNode()
     where.add((Constraint("cn", "cn", CharField()), 'exact', "foo"), AND)
     where.add((Constraint("givenName", "givenName", CharField()), 'exact', "bar"), OR)
     self.assertEquals(where_as_ldap(where), ("(|(cn=foo)(givenName=bar))", []))
コード例 #16
0
 def test_and(self):
     where = WhereNode()
     where.add((Constraint("cn", "cn", CharField()), 'exact', "foo"), AND)
     where.add((Constraint("givenName", "givenName",
                           CharField()), 'exact', "bar"), AND)
     self.assertEquals(where.as_sql(), ("(&(cn=foo)(givenName=bar))", []))
コード例 #17
0
ファイル: tests.py プロジェクト: Ozzee/password-safe-django
 def test_and(self):
     where = WhereNode()
     where.add((Constraint("cn", "cn", CharField()), 'exact', "foo"), AND)
     where.add((Constraint("givenName", "givenName", CharField()), 'exact', "bar"), AND)
     self.assertEquals(where.as_sql(), ("(&(cn=foo)(givenName=bar))", []))
コード例 #18
0
    def test_integer_field(self):
        where = WhereNode()
        where.add((Constraint("uid", "uid", IntegerField()), 'exact', 1), AND)
        self.assertEquals(where.as_sql(), ("(uid=1)", []))

        where = WhereNode()
        where.add((Constraint("uid", "uid", IntegerField()), 'gte', 1), AND)
        self.assertEquals(where.as_sql(), ("(uid>=1)", []))

        where = WhereNode()
        where.add((Constraint("uid", "uid", IntegerField()), 'lte', 1), AND)
        self.assertEquals(where.as_sql(), ("(uid<=1)", []))