Best Python code snippet using pytest-django_python
test_grammar.py
Source: test_grammar.py
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 ...
Check out the latest blogs from LambdaTest on this topic:
Hey Folks! Welcome back to the latest edition of LambdaTest’s product updates. Since programmer’s day is just around the corner, our incredible team of developers came up with several new features and enhancements to add some zing to your workflow. We at LambdaTest are continuously upgrading the features on our platform to make lives easy for the QA community. We are releasing new functionality almost every week.
Technical debt was originally defined as code restructuring, but in today’s fast-paced software delivery environment, it has evolved. Technical debt may be anything that the software development team puts off for later, such as ineffective code, unfixed defects, lacking unit tests, excessive manual tests, or missing automated tests. And, like financial debt, it is challenging to pay back.
Smartphones have changed the way humans interact with technology. Be it travel, fitness, lifestyle, video games, or even services, it’s all just a few touches away (quite literally so). We only need to look at the growing throngs of smartphone or tablet users vs. desktop users to grasp this reality.
If you are a web tester then somewhere down the road you will have to come across Selenium, an open-source test automation framework that has been on boom ever since its launch in 2004.
The web paradigm has changed considerably over the last few years. Web 2.0, a term coined way back in 1999, was one of the pivotal moments in the history of the Internet. UGC (User Generated Content), ease of use, and interoperability for the end-users were the key pillars of Web 2.0. Consumers who were only consuming content up till now started creating different forms of content (e.g., text, audio, video, etc.).
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!