Exemplo n.º 1
0
    def test_create_filter_key_2(self):
        """Verify create_filter_key() standardizes MySQL filters.
        """
        filter_1 = "phage.PhageID    =     Myrna"
        filter_2 = "phage.PhageID =      Myrna"

        key_1 = parsing.create_filter_key(filter_1)
        key_2 = parsing.create_filter_key(filter_2)

        self.assertEqual(key_1, key_2)
Exemplo n.º 2
0
    def test_create_filter_key_1(self, parse_filter_mock):
        """Verify create_filter_key() calls parse_filter()
        """
        filter = "gene.Notes = 'helix-turn-helix DNA binding domain protein'"

        filter_key = parsing.create_filter_key(filter)

        parse_filter_mock.assert_called()
Exemplo n.º 3
0
    def and_(self, filter):
        """Add an and conditional to the Filter object class.

        :param_filter: Formatted MySQL WHERE clause.
        :type_filter: str
        """
        if self._or_index < 0:
            self.new_or_()

        where_clause = q.build_where_clause(self.graph, filter)
        filter_key = parsing.create_filter_key(filter)

        or_block = self._filters[self._or_index]

        #Stores the BinaryExpression with a key of the Column/Operator pairing.
        or_block.update({filter_key: where_clause})

        self._updated = False
Exemplo n.º 4
0
    def remove(self, filter):
        """Remove an and filter from the current block of and conditionals.

        :param filter: Formatted MySQL WHERE clause.
        :type filter: str
        """
        filter_key = parsing.create_filter_key(filter)

        or_block = self._filters[self._or_index]

        # Indexes into the dictionary using the Column/Operator pairing.
        if filter_key in or_block.keys():
            or_block.pop(filter_key)
        else:
            raise IndexError(f"Filter {filter} is not within the current "
                             "block of and conditionals.")

        self._updated = False