How to use parse_query_string method in localstack

Best Python code snippet using localstack_python

query_unittest.py

Source: query_unittest.py Github

copy

Full Screen

...29 self.assertEqual(["a(x, y)", "b(p, q)"], self.query.get_sub_parts(query))30 query = ",,"31 self.assertEqual(["", "", ""], self.query.get_sub_parts(query))32 # pylint: disable=too-many-statements33 def test_parse_query_string(self):34 query = "TS(a, b, c)"35 root = self.query.parse_query_string(query)36 self.assertEqual("a", root.component)37 self.assertEqual(["b"], root.instances)38 self.assertEqual("c", root.metricName)39 query = "TS(a, *, m)"40 root = self.query.parse_query_string(query)41 self.assertEqual("a", root.component)42 self.assertEqual([], root.instances)43 self.assertEqual("m", root.metricName)44 query = "DEFAULT(0, TS(a, b, c))"45 root = self.query.parse_query_string(query)46 self.assertIsInstance(root, Default)47 self.assertIsInstance(root.constant, float)48 self.assertEqual(root.constant, 0)49 self.assertIsInstance(root.timeseries, TS)50 query = "DEFAULT(0, SUM(TS(a, a, a), TS(b, b, b)))"51 root = self.query.parse_query_string(query)52 self.assertIsInstance(root, Default)53 self.assertIsInstance(root.constant, float)54 self.assertIsInstance(root.timeseries, Sum)55 self.assertEqual(2, len(root.timeseries.timeSeriesList))56 self.assertIsInstance(root.timeseries.timeSeriesList[0], TS)57 self.assertIsInstance(root.timeseries.timeSeriesList[1], TS)58 query = "MAX(1, TS(a, a, a))"59 root = self.query.parse_query_string(query)60 self.assertIsInstance(root, Max)61 self.assertIsInstance(root.timeSeriesList[0], float)62 self.assertIsInstance(root.timeSeriesList[1], TS)63 query = "PERCENTILE(90, TS(a, a, a))"64 root = self.query.parse_query_string(query)65 self.assertIsInstance(root, Percentile)66 self.assertIsInstance(root.quantile, float)67 self.assertIsInstance(root.timeSeriesList[0], TS)68 query = "PERCENTILE(TS(a, a, a), 90)"69 with self.assertRaises(Exception):70 self.query.parse_query_string(query)71 query = "DIVIDE(TS(a, a, a), TS(b, b, b))"72 root = self.query.parse_query_string(query)73 self.assertIsInstance(root, Divide)74 self.assertIsInstance(root.timeSeries1, TS)75 self.assertIsInstance(root.timeSeries2, TS)76 # Dividing by a constant is fine77 query = "DIVIDE(TS(a, a, a), 90)"78 self.query.parse_query_string(query)79 root = self.query.parse_query_string(query)80 self.assertIsInstance(root, Divide)81 self.assertIsInstance(root.timeSeries1, TS)82 self.assertIsInstance(root.timeSeries2, float)83 # Must have two operands84 query = "DIVIDE(TS(a, a, a))"85 with self.assertRaises(Exception):86 self.query.parse_query_string(query)87 query = "MULTIPLY(TS(a, a, a), TS(b, b, b))"88 root = self.query.parse_query_string(query)89 self.assertIsInstance(root, Multiply)90 self.assertIsInstance(root.timeSeries1, TS)91 self.assertIsInstance(root.timeSeries2, TS)92 # Multiplying with a constant is fine.93 query = "MULTIPLY(TS(a, a, a), 10)"94 root = self.query.parse_query_string(query)95 self.assertIsInstance(root, Multiply)96 self.assertIsInstance(root.timeSeries1, TS)97 self.assertIsInstance(root.timeSeries2, float)98 # Must have two operands99 query = "MULTIPLY(TS(a, a, a))"100 with self.assertRaises(Exception):101 self.query.parse_query_string(query)102 query = "SUBTRACT(TS(a, a, a), TS(b, b, b))"103 root = self.query.parse_query_string(query)104 self.assertIsInstance(root, Subtract)105 self.assertIsInstance(root.timeSeries1, TS)106 self.assertIsInstance(root.timeSeries2, TS)107 # Multiplying with a constant is fine.108 query = "SUBTRACT(TS(a, a, a), 10)"109 root = self.query.parse_query_string(query)110 self.assertIsInstance(root, Subtract)111 self.assertIsInstance(root.timeSeries1, TS)112 self.assertIsInstance(root.timeSeries2, float)113 # Must have two operands114 query = "SUBTRACT(TS(a, a, a))"115 with self.assertRaises(Exception):116 self.query.parse_query_string(query)117 query = "RATE(TS(a, a, a))"118 root = self.query.parse_query_string(query)119 self.assertIsInstance(root, Rate)120 self.assertIsInstance(root.timeSeries, TS)121 # Must have one operand only122 query = "RATE(TS(a, a, a), TS(b, b, b))"123 with self.assertRaises(Exception):...

Full Screen

Full Screen

test_aws_responses.py

Source: test_aws_responses.py Github

copy

Full Screen

...48@pytest.mark.parametrize("test_input", [multiple_root, empty_dict, result_raw_class_value])49def test_to_xml_raise_error_malformeddict(test_input):50 with pytest.raises(Exception):51 to_xml(test_input)52def test_parse_query_string():53 assert parse_query_string("") == {}54 assert parse_query_string("?a=1") == {"a": "1"}55 assert parse_query_string("?a=1&b=foo2") == {"a": "1", "b": "foo2"}56 assert parse_query_string("http:/​/​example.com") == {}57 assert parse_query_string("http:/​/​example.com/​foo/​bar") == {}58 assert parse_query_string("http:/​/​example.com/​foo/​bar#test") == {}59 assert parse_query_string("http:/​/​example.com/​foo/​bar?a=1") == {"a": "1"}60 assert parse_query_string("http:/​/​example.com/​foo/​bar?foo=1&1=2") == {"foo": "1", "1": "2"}61 assert parse_query_string("?foo=1&foo=2&", multi_values=True) == {"foo": ["1", "2"]}62 assert parse_query_string("?a=1&a=2&b=0&a=3", multi_values=True) == {63 "a": ["1", "2", "3"],64 "b": ["0"],...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Complete Guide To Styling Forms With CSS Accent Color

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.).

A Reconsideration of Software Testing Metrics

There is just one area where each member of the software testing community has a distinct point of view! Metrics! This contentious issue sparks intense disputes, and most conversations finish with no definitive conclusion. It covers a wide range of topics: How can testing efforts be measured? What is the most effective technique to assess effectiveness? Which of the many components should be quantified? How can we measure the quality of our testing performance, among other things?

Unveiling Samsung Galaxy Z Fold4 For Mobile App Testing

Hey LambdaTesters! We’ve got something special for you this week. ????

How To Automate Toggle Buttons In Selenium Java

If you pay close attention, you’ll notice that toggle switches are all around us because lots of things have two simple states: either ON or OFF (in binary 1 or 0).

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 localstack 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