How to use test_queries method in pytest-django

Best Python code snippet using pytest-django_python

test_grammar.py

Source:test_grammar.py Github

copy

Full Screen

1import inspect2import os3import re4from tincmmgr.grammar import TINCMMQueryHandler5from tincmmgr import TINCMMException6import unittest2 as unittest7class TINCMMQueryGrammarTests(unittest.TestCase):8 def test_positive_select_queries(self):9 test_queries = []10 test_queries.append("select metadata")11 handler = TINCMMQueryHandler(test_queries)12 self.assertEquals(len(handler.query_list), len(test_queries))13 def test_negative_select_queries(self):14 test_queries = []15 test_queries.append("select")16 test_queries.append("select !")17 test_queries.append("select metadata remaining text")18 test_queries.append("select *;")19 test_queries.append("select metadata1, metadata2, metadata3")20 for query in test_queries:21 try:22 handler = TINCMMQueryHandler(query)23 except TINCMMException:24 continue25 self.fail("Query %s did not throw an exception" %query)26 def test_positive_insert_queries(self):27 test_queries = []28 test_queries.append("insert metadata=value")29 test_queries.append("insert product_version = 'gpdb: , hawq: '")30 test_queries.append("insert tags='smoke'")31 test_queries.append("insert optimizer_mode=on")32 test_queries.append("insert optimizer_mode = off")33 test_queries.append("insert product_version = 'gpdb: [4.2-], hawq: [1.1.0.0-1.2.0.0]'")34 handler = TINCMMQueryHandler(test_queries)35 self.assertEquals(len(handler.query_list), len(test_queries))36 def test_negative_insert_queries(self):37 test_queries = []38 test_queries.append("insert")39 test_queries.append("insert metadata")40 test_queries.append("insert metadata value")41 test_queries.append("insert metadata =")42 for query in test_queries:43 try:44 handler = TINCMMQueryHandler(query)45 except TINCMMException:46 continue47 self.fail("Query %s did not throw an exception" %query)48 def test_positive_update_queries(self):49 test_queries = []50 test_queries.append("update metadata=value")51 test_queries.append("update product_version = 'gpdb: , hawq: '")52 test_queries.append("update tags='smoke'")53 test_queries.append("update optimizer_mode=on")54 test_queries.append("update optimizer_mode = off")55 test_queries.append("update product_version = 'gpdb: [4.2-], hawq: [1.1.0.0-1.2.0.0]'")56 handler = TINCMMQueryHandler(test_queries)57 self.assertEquals(len(handler.query_list), len(test_queries))58 def test_negative_update_queries(self):59 test_queries = []60 test_queries.append("update")61 test_queries.append("update metadata")62 test_queries.append("update metadata value")63 test_queries.append("update metadata =")64 for query in test_queries:65 try:66 handler = TINCMMQueryHandler(query)67 except TINCMMException:68 continue69 self.fail("Query %s did not throw an exception" %query)70 def test_positive_delete_queries(self):71 test_queries = []72 test_queries.append("delete metadata")73 test_queries.append("delete product_version=gpdb:")74 test_queries.append("delete product_version='gpdb: 4.2.x, hawq: 1.x'")75 test_queries.append("delete tags=smoke")76 handler = TINCMMQueryHandler(test_queries)77 self.assertEquals(len(handler.query_list), len(test_queries))78 def test_negative_delete_queries(self):79 test_queries = []80 test_queries.append("delete")81 test_queries.append("delete !")82 test_queries.append("delete metadata remaining text")83 test_queries.append("delete *;")84 test_queries.append("delete metadata1, metadata2, metadata3")85 test_queries.append("delete *")86 test_queries.append("delete product_version=")87 test_queries.append("delete tags=")88 test_queries.append("delete some_other_metadata=value")89 for query in test_queries:90 try:91 handler = TINCMMQueryHandler(query)92 except TINCMMException:93 continue94 self.fail("Query %s did not throw an exception" %query)95 96 97 98 99 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytest-django automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful