コード例 #1
0
    def test_parse_cmd_string_5(self):
        """Verify parse_cmd_string() raises ValueError from incomplete clause.
        """
        filters_string = ("phage.PhageID LIKE Trixie OR")

        with self.assertRaises(ValueError):
            parsed_cmd_line = parsing.parse_cmd_string(filters_string)
コード例 #2
0
ファイル: test_parsing.py プロジェクト: tmavrich/pdm_utils
    def test_parse_cmd_string_1(self):
        filters_string = "phage.PhageID=Trixie AND gene.Notes=Antirepressor"

        parsed_string = parsing.parse_cmd_string(filters_string)

        self.assertTrue(len(parsed_string) == 2)
        self.assertEqual(parsed_string[0], ["phage.PhageID=Trixie"])
        self.assertEqual(parsed_string[1], ["gene.Notes=Antirepressor"])
コード例 #3
0
ファイル: test_parsing.py プロジェクト: tmavrich/pdm_utils
    def test_parse_cmd_string_2(self):
        filters_string = ("phage.PhageID = Trixie OR "
                          "gene.Notes  = Antirepressor")

        parsed_string = parsing.parse_cmd_string(filters_string)

        self.assertTrue(len(parsed_string) == 1)
        self.assertTrue(len(parsed_string[0]) == 2)
        self.assertEqual(parsed_string[0][0], "phage.PhageID = Trixie")
        self.assertEqual(parsed_string[0][1], "gene.Notes  = Antirepressor")
コード例 #4
0
    def test_parse_cmd_string_1(self):
        """Verify parse_cmd_string() recognizes and splits WHERE clauses.
        """
        filters_string = "phage.PhageID=Trixie AND gene.Notes=Antirepressor"

        parsed_string = parsing.parse_cmd_string(filters_string)

        self.assertTrue(len(parsed_string) == 1)
        self.assertEqual(parsed_string[0][0], "phage.PhageID=Trixie")
        self.assertEqual(parsed_string[0][1], "gene.Notes=Antirepressor")
コード例 #5
0
    def test_parse_cmd_string_2(self):
        """Verify parse_cmd_string() groups ORed WHERE clauses.
        """
        filters_string = ("phage.PhageID = Trixie OR "
                          "gene.Notes  = Antirepressor")

        parsed_string = parsing.parse_cmd_string(filters_string)

        self.assertTrue(len(parsed_string) == 2)
        self.assertTrue(len(parsed_string[0]) == 1)
        self.assertEqual(parsed_string[0][0], "phage.PhageID = Trixie")
        self.assertEqual(parsed_string[1][0], "gene.Notes  = Antirepressor")
コード例 #6
0
ファイル: test_parsing.py プロジェクト: stjacqrm/pdm_utils
    def test_parse_cmd_string_4(self):
        """Verify parse_cmd_string() recognizes LIKE and IS NOT operators.
        """
        filters_string = ("phage.PhageID LIKE Trixie OR "
                          "gene.Notes IS NOT Antirepressor")
 
        parsed_string = parsing.parse_cmd_string(filters_string)

        self.assertTrue(len(parsed_string) == 2)
        self.assertTrue(len(parsed_string[0]) == 1)
        self.assertEqual(parsed_string[0][0], "phage.PhageID LIKE Trixie")
        self.assertEqual(parsed_string[1][0], "gene.Notes IS NOT Antirepressor")
コード例 #7
0
    def add(self, filter_string):
        """Add a MySQL where filter(s) to the Filter object class.

        :param filter: Formatted MySQL WHERE clause.
        :type filter: str
        """
        filters = parsing.parse_cmd_string(filter_string)
        while (filters):
            and_filters = filters[0]
            for filter in and_filters:
                self.and_(filter)

            filters.pop(0)

            if filters:
                self.new_or_()
コード例 #8
0
ファイル: test_parsing.py プロジェクト: tmavrich/pdm_utils
    def test_parse_cmd_filter_5(self):
        filters_string = ("phage.PhageID LIKE Trixie")

        parsed_filters = parsing.parse_cmd_string(filters_string)
コード例 #9
0
ファイル: test_parsing.py プロジェクト: tmavrich/pdm_utils
    def test_parse_cmd_string_5(self):
        filters_string = ("phage.PhageID LIKE Trixie OR")

        with self.assertRaises(ValueError):
            parsed_cmd_line = parsing.parse_cmd_string(filters_string)
コード例 #10
0
    def test_parse_cmd_filter_3(self):
        """Verify parse_cmd_string() recognizes LIKE operator.
        """
        filters_string = ("phage.PhageID LIKE Trixie")

        parsed_filters = parsing.parse_cmd_string(filters_string)