Exemple #1
0
 def test_no_body(self):
     query = """
     -- name: test
     -- documentation1
     -- documentation2
     """
     with self.assertRaises(ParseError):
         parse_query(LineParser(query))
Exemple #2
0
 def test_no_body(self):
     query = """
     -- name: test
     -- documentation1
     -- documentation2
     """
     with self.assertRaises(ParseError):
         parse_query(LineParser(query))
Exemple #3
0
 def test_simple_query(self):
     query = """
     -- name: test
     QUERY BODY
     """
     q = parse_query(LineParser(query))
     self.assertEqual(q.name, 'test')
     self.assertFalse(q.statement)
     self.assertEqual(q.doc, '')
     self.assertEqual(q.body.strip(), 'QUERY BODY')
Exemple #4
0
 def test_simple_query(self):
     query = """
     -- name: test
     QUERY BODY
     """
     q = parse_query(LineParser(query))
     self.assertEqual(q.name, 'test')
     self.assertFalse(q.statement)
     self.assertEqual(q.doc, '')
     self.assertEqual(q.body.strip(), 'QUERY BODY')
Exemple #5
0
 def test_doc_query(self):
     query = """
     -- name: test
     -- documentation1
     -- documentation2
     QUERY BODY
     """
     q = parse_query(LineParser(query))
     self.assertEqual(q.name, 'test')
     self.assertEqual(q.doc.strip(), 'documentation1\ndocumentation2')
     self.assertEqual(q.body.strip(), 'QUERY BODY')
Exemple #6
0
 def test_doc_query(self):
     query = """
     -- name: test
     -- documentation1
     -- documentation2
     QUERY BODY
     """
     q = parse_query(LineParser(query))
     self.assertEqual(q.name, 'test')
     self.assertEqual(q.doc.strip(), 'documentation1\ndocumentation2')
     self.assertEqual(q.body.strip(), 'QUERY BODY')
Exemple #7
0
 def test_include_comment_query(self):
     query = """
     -- name: test
     QUERY BODY 1
     -- comment
     QUERY BODY 2
     """
     q = parse_query(LineParser(query))
     self.assertEqual(q.name, 'test')
     self.assertEqual(q.doc, '')
     self.assertEqual([l.strip() for l in q.body.splitlines()],
                      ['QUERY BODY 1', '-- comment', 'QUERY BODY 2', ''])
Exemple #8
0
 def test_include_comment_query(self):
     query = """
     -- name: test
     QUERY BODY 1
     -- comment
     QUERY BODY 2
     """
     q = parse_query(LineParser(query))
     self.assertEqual(q.name, 'test')
     self.assertEqual(q.doc, '')
     self.assertEqual([l.strip() for l in q.body.splitlines()],
                      ['QUERY BODY 1', '-- comment', 'QUERY BODY 2', ''])
Exemple #9
0
    def test_multiline_query(self):
        query = """
        -- name: test
        QUERY BODY 1

        QUERY BODY 2

        QUERY BODY 3
        """
        q = parse_query(LineParser(query))
        self.assertEqual(q.name, 'test')
        self.assertEqual(q.doc, '')
        self.assertEqual([l.strip() for l in q.body.splitlines()],
                         ['QUERY BODY 1', '', 'QUERY BODY 2', '', 'QUERY BODY 3', ''])
Exemple #10
0
    def test_multiline_query(self):
        query = """
        -- name: test
        QUERY BODY 1

        QUERY BODY 2

        QUERY BODY 3
        """
        q = parse_query(LineParser(query))
        self.assertEqual(q.name, 'test')
        self.assertEqual(q.doc, '')
        self.assertEqual(
            [l.strip() for l in q.body.splitlines()],
            ['QUERY BODY 1', '', 'QUERY BODY 2', '', 'QUERY BODY 3', ''])
Exemple #11
0
 def test_empty(self):
     with self.assertRaises(ParseError):
         parse_query(LineParser(""))
Exemple #12
0
 def test_no_doc_or_body(self):
     query = """
     -- name: test
     """
     with self.assertRaises(ParseError):
         parse_query(LineParser(query))
Exemple #13
0
 def test_empty(self):
     with self.assertRaises(ParseError):
         parse_query(LineParser(""))
Exemple #14
0
 def test_no_doc_or_body(self):
     query = """
     -- name: test
     """
     with self.assertRaises(ParseError):
         parse_query(LineParser(query))