예제 #1
0
def test_simple():
    res = process_params(Treatment, [], id=0)
    assert len(res) == 1
    assert str(Treatment.id == 0) == str(res[0])
    res = process_params(Treatment, [], name=0)
    assert len(res) == 1
    assert str(Treatment.name == 0) == str(res[0])
예제 #2
0
    def __call__(self, klass, class_found):
        """
        Process every node.
        """
        # Si l'on a des paramètres bruts, c'est que l'on est une feuille de
        # l'arbre
        # On retourne alors le process des paramètres
        if self.operand:
            clauses = process_params(klass, class_found, **self.operand)
        else:
            # Sinon, nous avons des enfants et l'on retourne l'opération que l'on
            # représente sur le retour des enfants.
            clauses = []
            if self.lhs:
                clauses.append(self.lhs(klass, class_found))
            if self.rhs:
                clauses.append(self.rhs(klass, class_found))

        return self.operator(*clauses)
예제 #3
0
    def __call__(self, klass, class_found):
        """
        Process every node.
        """
        # Si l'on a des paramètres bruts, c'est que l'on est une feuille de
        # l'arbre
        # On retourne alors le process des paramètres
        if self.operand:
            clauses = process_params(klass, class_found, **self.operand)
        else:
            # Sinon, nous avons des enfants et l'on retourne l'opération que l'on
            # représente sur le retour des enfants.
            clauses = []
            if self.lhs:
                clauses.append(self.lhs(klass, class_found))
            if self.rhs:
                clauses.append(self.rhs(klass, class_found))

        return self.operator(*clauses)
예제 #4
0
def test_multiple_relation():
    joined_class = []
    process_params(Treatment, joined_class, status__name='test',
                         status__id=0)
    assert len(joined_class) == 1
    assert Status in joined_class
예제 #5
0
def test_simple_relation():
    joined_class = []
    res = process_params(Treatment, joined_class, status__name='test')
    assert len(joined_class)
    assert Status in joined_class
    assert str(Status.name == 'test') == str(res[0])
예제 #6
0
def test_unknow_attr():
    process_params(Treatment, [], test='toto')
예제 #7
0
def test_in_operator():
    res = process_params(Treatment, [], id__in=[0])
    assert len(res) == 1
    assert str(Treatment.id.in_([0])) == str(res[0])
예제 #8
0
def test_ge_operator():
    res = process_params(Treatment, [], id__ge=0)
    assert len(res) == 1
    assert str(Treatment.id >= 0) == str(res[0])
예제 #9
0
def test_multiple_key():
    res = process_params(Treatment, [], id=0, name='toto')
    assert len(res) == 2