How to use assertSequenceEqual method in autotest

Best Python code snippet using autotest_python

test_cql_parsing.py

Source:test_cql_parsing.py Github

copy

Full Screen

...20from ..cql3handling import CqlRuleSet21class TestCqlParsing(TestCase):22 def test_parse_string_literals(self):23 for n in ["'eggs'", "'Sausage 1'", "'spam\nspam\n\tsausage'", "''"]:24 self.assertSequenceEqual(tokens_with_types(CqlRuleSet.lex(n)),25 [(n, 'quotedStringLiteral')])26 self.assertSequenceEqual(tokens_with_types(CqlRuleSet.lex("'eggs'")),27 [("'eggs'", 'quotedStringLiteral')])28 tokens = CqlRuleSet.lex("'spam\nspam\n\tsausage'")29 tokens = CqlRuleSet.cql_massage_tokens(tokens)30 self.assertEqual(tokens[0][0], "quotedStringLiteral")31 tokens = CqlRuleSet.lex("'spam\nspam\n")32 tokens = CqlRuleSet.cql_massage_tokens(tokens)33 self.assertEqual(tokens[0][0], "unclosedString")34 tokens = CqlRuleSet.lex("'foo bar' 'spam\nspam\n")35 tokens = CqlRuleSet.cql_massage_tokens(tokens)36 self.assertEqual(tokens[1][0], "unclosedString")37 def test_parse_pgstring_literals(self):38 for n in ["$$eggs$$", "$$Sausage 1$$", "$$spam\nspam\n\tsausage$$", "$$$$"]:39 self.assertSequenceEqual(tokens_with_types(CqlRuleSet.lex(n)),40 [(n, 'pgStringLiteral')])41 self.assertSequenceEqual(tokens_with_types(CqlRuleSet.lex("$$eggs$$")),42 [("$$eggs$$", 'pgStringLiteral')])43 tokens = CqlRuleSet.lex("$$spam\nspam\n\tsausage$$")44 tokens = CqlRuleSet.cql_massage_tokens(tokens)45 # [('pgStringLiteral', '$$spam\nspam\n\tsausage$$', (0, 22))]46 self.assertEqual(tokens[0][0], "pgStringLiteral")47 tokens = CqlRuleSet.lex("$$spam\nspam\n")48 tokens = CqlRuleSet.cql_massage_tokens(tokens)49 # [('unclosedPgString', '$$', (0, 2)), ('identifier', 'spam', (2, 6)), ('identifier', 'spam', (7, 11))]50 self.assertEqual(tokens[0][0], "unclosedPgString")51 tokens = CqlRuleSet.lex("$$foo bar$$ $$spam\nspam\n")52 tokens = CqlRuleSet.cql_massage_tokens(tokens)53 # [('pgStringLiteral', '$$foo bar$$', (0, 11)), ('unclosedPgString', '$$', (12, 14)), ('identifier', 'spam', (14, 18)), ('identifier', 'spam', (19, 23))]54 self.assertEqual(tokens[0][0], "pgStringLiteral")55 self.assertEqual(tokens[1][0], "unclosedPgString")56 def test_parse_numbers(self):57 for n in ['6', '398', '18018']:58 self.assertSequenceEqual(tokens_with_types(CqlRuleSet.lex(n)),59 [(n, 'wholenumber')])60 def test_parse_uuid(self):61 uuids = ['4feeae80-e9cc-11e4-b571-0800200c9a66',62 '7142303f-828f-4806-be9e-7a973da0c3f9',63 'dff8d435-9ca0-487c-b5d0-b0fe5c5768a8']64 for u in uuids:65 self.assertSequenceEqual(tokens_with_types(CqlRuleSet.lex(u)),66 [(u, 'uuid')])67 def test_comments_in_string_literals(self):68 comment_strings = ["'sausage -- comment'",69 "'eggs and spam // comment string'",70 "'spam eggs sausage and spam /* still in string'"]71 for s in comment_strings:72 self.assertSequenceEqual(tokens_with_types(CqlRuleSet.lex(s)),73 [(s, 'quotedStringLiteral')])74 def test_colons_in_string_literals(self):75 comment_strings = ["'Movie Title: The Movie'",76 "':a:b:c:'",77 "'(>>=) :: (Monad m) => m a -> (a -> m b) -> m b'"]78 for s in comment_strings:79 self.assertSequenceEqual(tokens_with_types(CqlRuleSet.lex(s)),80 [(s, 'quotedStringLiteral')])81 def test_partial_parsing(self):82 [parsed] = CqlRuleSet.cql_parse('INSERT INTO ks.test')83 self.assertSequenceEqual(parsed.matched, [])84 self.assertSequenceEqual(tokens_with_types(parsed.remainder),85 [('INSERT', 'reserved_identifier'),86 ('INTO', 'reserved_identifier'),87 ('ks', 'identifier'),88 ('.', 'op'),89 ('test', 'identifier')])90 def test_parse_select(self):91 parsed = parse_cqlsh_statements('SELECT FROM ks.tab;')92 self.assertSequenceEqual(tokens_with_types(parsed),93 [('SELECT', 'reserved_identifier'),94 ('FROM', 'reserved_identifier'),95 ('ks', 'identifier'),96 ('.', 'op'),97 ('tab', 'identifier'),98 (';', 'endtoken')])99 parsed = parse_cqlsh_statements('SELECT FROM "MyTable";')100 self.assertSequenceEqual(tokens_with_types(parsed),101 [('SELECT', 'reserved_identifier'),102 ('FROM', 'reserved_identifier'),103 ('"MyTable"', 'quotedName'),104 (';', 'endtoken')])105 parsed = parse_cqlsh_statements(106 'SELECT FROM tab WHERE foo = 3;')107 self.assertSequenceEqual(tokens_with_types(parsed),108 [('SELECT', 'reserved_identifier'),109 ('FROM', 'reserved_identifier'),110 ('tab', 'identifier'),111 ('WHERE', 'reserved_identifier'),112 ('foo', 'identifier'),113 ('=', 'op'),114 ('3', 'wholenumber'),115 (';', 'endtoken')])116 parsed = parse_cqlsh_statements(117 'SELECT FROM tab ORDER BY event_id DESC LIMIT 1000')118 self.assertSequenceEqual(tokens_with_types(parsed),119 [('SELECT', 'reserved_identifier'),120 ('FROM', 'reserved_identifier'),121 ('tab', 'identifier'),122 ('ORDER', 'reserved_identifier'),123 ('BY', 'reserved_identifier'),124 ('event_id', 'identifier'),125 ('DESC', 'reserved_identifier'),126 ('LIMIT', 'reserved_identifier'),127 ('1000', 'wholenumber')])128 parsed = parse_cqlsh_statements(129 'SELECT FROM tab WHERE clustering_column > 200 '130 'AND clustering_column < 400 ALLOW FILTERING')131 self.assertSequenceEqual(tokens_with_types(parsed),132 [('SELECT', 'reserved_identifier'),133 ('FROM', 'reserved_identifier'),134 ('tab', 'identifier'),135 ('WHERE', 'reserved_identifier'),136 ('clustering_column', 'identifier'),137 ('>', 'cmp'),138 ('200', 'wholenumber'),139 ('AND', 'reserved_identifier'),140 ('clustering_column', 'identifier'),141 ('<', 'cmp'),142 ('400', 'wholenumber'),143 # 'allow' and 'filtering' are not keywords144 ('ALLOW', 'reserved_identifier'),145 ('FILTERING', 'identifier')])146 def test_parse_insert(self):147 parsed = parse_cqlsh_statements('INSERT INTO mytable (x) VALUES (2);')148 self.assertSequenceEqual(tokens_with_types(parsed),149 [('INSERT', 'reserved_identifier'),150 ('INTO', 'reserved_identifier'),151 ('mytable', 'identifier'),152 ('(', 'op'),153 ('x', 'identifier'),154 (')', 'op'),155 ('VALUES', 'identifier'),156 ('(', 'op'),157 ('2', 'wholenumber'),158 (')', 'op'),159 (';', 'endtoken')])160 parsed = parse_cqlsh_statements(161 "INSERT INTO mytable (x, y) VALUES (2, 'eggs');")162 self.assertSequenceEqual(tokens_with_types(parsed),163 [('INSERT', 'reserved_identifier'),164 ('INTO', 'reserved_identifier'),165 ('mytable', 'identifier'),166 ('(', 'op'),167 ('x', 'identifier'),168 (',', 'op'),169 ('y', 'identifier'),170 (')', 'op'),171 ('VALUES', 'identifier'),172 ('(', 'op'),173 ('2', 'wholenumber'),174 (',', 'op'),175 ("'eggs'", 'quotedStringLiteral'),176 (')', 'op'),177 (';', 'endtoken')])178 parsed = parse_cqlsh_statements(179 "INSERT INTO mytable (x, y) VALUES (2, 'eggs');")180 self.assertSequenceEqual(tokens_with_types(parsed),181 [('INSERT', 'reserved_identifier'),182 ('INTO', 'reserved_identifier'),183 ('mytable', 'identifier'),184 ('(', 'op'),185 ('x', 'identifier'),186 (',', 'op'),187 ('y', 'identifier'),188 (')', 'op'),189 ('VALUES', 'identifier'),190 ('(', 'op'),191 ('2', 'wholenumber'),192 (',', 'op'),193 ("'eggs'", 'quotedStringLiteral'),194 (')', 'op'),195 (';', 'endtoken')])196 parsed = parse_cqlsh_statements(197 "INSERT INTO mytable (ids) VALUES "198 "(7ee251da-af52-49a4-97f4-3f07e406c7a7) "199 "USING TTL 86400;")200 self.assertSequenceEqual(tokens_with_types(parsed),201 [('INSERT', 'reserved_identifier'),202 ('INTO', 'reserved_identifier'),203 ('mytable', 'identifier'),204 ('(', 'op'),205 ('ids', 'identifier'),206 (')', 'op'),207 ('VALUES', 'identifier'),208 ('(', 'op'),209 ('7ee251da-af52-49a4-97f4-3f07e406c7a7', 'uuid'),210 (')', 'op'),211 ('USING', 'reserved_identifier'),212 ('TTL', 'identifier'),213 ('86400', 'wholenumber'),214 (';', 'endtoken')])215 parsed = parse_cqlsh_statements(216 "INSERT INTO test_table (username) VALUES ('Albert') "217 "USING TIMESTAMP 1240003134 AND TTL 600;")218 self.assertSequenceEqual(tokens_with_types(parsed),219 [('INSERT', 'reserved_identifier'),220 ('INTO', 'reserved_identifier'),221 ('test_table', 'identifier'),222 ('(', 'op'),223 ('username', 'identifier'),224 (')', 'op'),225 ('VALUES', 'identifier'),226 ('(', 'op'),227 ("'Albert'", 'quotedStringLiteral'),228 (')', 'op'),229 ('USING', 'reserved_identifier'),230 ('TIMESTAMP', 'identifier'),231 ('1240003134', 'wholenumber'),232 ('AND', 'reserved_identifier'),233 ('TTL', 'identifier'),234 ('600', 'wholenumber'),235 (';', 'endtoken')])236 def test_parse_update(self):237 parsed = parse_cqlsh_statements(238 "UPDATE tab SET x = 15 WHERE y = 'eggs';")239 self.assertSequenceEqual(tokens_with_types(parsed),240 [('UPDATE', 'reserved_identifier'),241 ('tab', 'identifier'),242 ('SET', 'reserved_identifier'),243 ('x', 'identifier'),244 ('=', 'op'),245 ('15', 'wholenumber'),246 ('WHERE', 'reserved_identifier'),247 ('y', 'identifier'),248 ('=', 'op'),249 ("'eggs'", 'quotedStringLiteral'),250 (';', 'endtoken')])251 parsed = parse_cqlsh_statements(252 "UPDATE tab USING TTL 432000 SET x = 15 WHERE y = 'eggs';")253 self.assertSequenceEqual(tokens_with_types(parsed),254 [('UPDATE', 'reserved_identifier'),255 ('tab', 'identifier'),256 ('USING', 'reserved_identifier'),257 ('TTL', 'identifier'),258 ('432000', 'wholenumber'),259 ('SET', 'reserved_identifier'),260 ('x', 'identifier'),261 ('=', 'op'),262 ('15', 'wholenumber'),263 ('WHERE', 'reserved_identifier'),264 ('y', 'identifier'),265 ('=', 'op'),266 ("'eggs'", 'quotedStringLiteral'),267 (';', 'endtoken')])268 parsed = parse_cqlsh_statements(269 "UPDATE tab SET x = 15, y = 'sausage' "270 "WHERE y = 'eggs';")271 self.assertSequenceEqual(tokens_with_types(parsed),272 [('UPDATE', 'reserved_identifier'),273 ('tab', 'identifier'),274 ('SET', 'reserved_identifier'),275 ('x', 'identifier'),276 ('=', 'op'),277 ('15', 'wholenumber'),278 (',', 'op'),279 ('y', 'identifier'),280 ('=', 'op'),281 ("'sausage'", 'quotedStringLiteral'),282 ('WHERE', 'reserved_identifier'),283 ('y', 'identifier'),284 ('=', 'op'),285 ("'eggs'", 'quotedStringLiteral'),286 (';', 'endtoken')])287 parsed = parse_cqlsh_statements(288 "UPDATE tab SET x = 15 "289 "WHERE y IN ('eggs', 'sausage', 'spam');")290 self.assertSequenceEqual(tokens_with_types(parsed),291 [('UPDATE', 'reserved_identifier'),292 ('tab', 'identifier'),293 ('SET', 'reserved_identifier'),294 ('x', 'identifier'),295 ('=', 'op'),296 ('15', 'wholenumber'),297 ('WHERE', 'reserved_identifier'),298 ('y', 'identifier'),299 ('IN', 'reserved_identifier'),300 ('(', 'op'),301 ("'eggs'", 'quotedStringLiteral'),302 (',', 'op'),303 ("'sausage'", 'quotedStringLiteral'),304 (',', 'op'),305 ("'spam'", 'quotedStringLiteral'),306 (')', 'op'),307 (';', 'endtoken')])308 parsed = parse_cqlsh_statements(309 "UPDATE tab SET x = 15 "310 "WHERE y = 'spam' IF z = 'sausage';")311 self.assertSequenceEqual(tokens_with_types(parsed),312 [('UPDATE', 'reserved_identifier'),313 ('tab', 'identifier'),314 ('SET', 'reserved_identifier'),315 ('x', 'identifier'),316 ('=', 'op'),317 ('15', 'wholenumber'),318 ('WHERE', 'reserved_identifier'),319 ('y', 'identifier'),320 ('=', 'op'),321 ("'spam'", 'quotedStringLiteral'),322 ('IF', 'reserved_identifier'),323 ('z', 'identifier'),324 ('=', 'op'),325 ("'sausage'", 'quotedStringLiteral'),326 (';', 'endtoken')])327 parsed = parse_cqlsh_statements(328 "UPDATE tab SET x = 15 WHERE y = 'spam' "329 "IF z = 'sausage' AND w = 'spam';")330 self.assertSequenceEqual(tokens_with_types(parsed),331 [('UPDATE', 'reserved_identifier'),332 ('tab', 'identifier'),333 ('SET', 'reserved_identifier'),334 ('x', 'identifier'),335 ('=', 'op'),336 ('15', 'wholenumber'),337 ('WHERE', 'reserved_identifier'),338 ('y', 'identifier'),339 ('=', 'op'),340 ("'spam'", 'quotedStringLiteral'),341 ('IF', 'reserved_identifier'),342 ('z', 'identifier'),343 ('=', 'op'),344 ("'sausage'", 'quotedStringLiteral'),345 ('AND', 'reserved_identifier'),346 ('w', 'identifier'),347 ('=', 'op'),348 ("'spam'", 'quotedStringLiteral'),349 (';', 'endtoken')])350 parsed = parse_cqlsh_statements(351 "UPDATE tab SET x = 15 WHERE y = 'spam' IF EXISTS")352 self.assertSequenceEqual(tokens_with_types(parsed),353 [('UPDATE', 'reserved_identifier'),354 ('tab', 'identifier'),355 ('SET', 'reserved_identifier'),356 ('x', 'identifier'),357 ('=', 'op'),358 ('15', 'wholenumber'),359 ('WHERE', 'reserved_identifier'),360 ('y', 'identifier'),361 ('=', 'op'),362 ("'spam'", 'quotedStringLiteral'),363 ('IF', 'reserved_identifier'),364 ('EXISTS', 'identifier')])365 def test_parse_delete(self):366 parsed = parse_cqlsh_statements(367 "DELETE FROM songs WHERE songid = 444;")368 self.assertSequenceEqual(tokens_with_types(parsed),369 [('DELETE', 'reserved_identifier'),370 ('FROM', 'reserved_identifier'),371 ('songs', 'identifier'),372 ('WHERE', 'reserved_identifier'),373 ('songid', 'identifier'),374 ('=', 'op'),375 ('444', 'wholenumber'),376 (';', 'endtoken')])377 parsed = parse_cqlsh_statements(378 "DELETE FROM songs WHERE name IN "379 "('Yellow Submarine', 'Eleanor Rigby');")380 self.assertSequenceEqual(tokens_with_types(parsed),381 [('DELETE', 'reserved_identifier'),382 ('FROM', 'reserved_identifier'),383 ('songs', 'identifier'),384 ('WHERE', 'reserved_identifier'),385 ('name', 'identifier'),386 ('IN', 'reserved_identifier'),387 ('(', 'op'),388 ("'Yellow Submarine'", 'quotedStringLiteral'),389 (',', 'op'),390 ("'Eleanor Rigby'", 'quotedStringLiteral'),391 (')', 'op'),392 (';', 'endtoken')])393 parsed = parse_cqlsh_statements(394 "DELETE task_map ['2014-12-25'] FROM tasks WHERE user_id = 'Santa';")395 self.assertSequenceEqual(tokens_with_types(parsed),396 [('DELETE', 'reserved_identifier'),397 ('task_map', 'identifier'),398 ('[', 'brackets'),399 ("'2014-12-25'", 'quotedStringLiteral'),400 (']', 'brackets'),401 ('FROM', 'reserved_identifier'),402 ('tasks', 'identifier'),403 ('WHERE', 'reserved_identifier'),404 ('user_id', 'identifier'),405 ('=', 'op'),406 ("'Santa'", 'quotedStringLiteral'),407 (';', 'endtoken')])408 parsed = parse_cqlsh_statements(409 "DELETE my_list[0] FROM lists WHERE user_id = 'Jim';")410 self.assertSequenceEqual(tokens_with_types(parsed),411 [('DELETE', 'reserved_identifier'),412 ('my_list', 'identifier'),413 ('[', 'brackets'),414 ('0', 'wholenumber'),415 (']', 'brackets'),416 ('FROM', 'reserved_identifier'),417 ('lists', 'identifier'),418 ('WHERE', 'reserved_identifier'),419 ('user_id', 'identifier'),420 ('=', 'op'),421 ("'Jim'", 'quotedStringLiteral'),422 (';', 'endtoken')])423 def test_parse_batch(self):424 pass425 def test_parse_create_keyspace(self):426 parsed = parse_cqlsh_statements(427 "CREATE KEYSPACE ks WITH REPLICATION = "428 "{'class': 'SimpleStrategy', 'replication_factor': 1};")429 self.assertSequenceEqual(tokens_with_types(parsed),430 [('CREATE', 'reserved_identifier'),431 ('KEYSPACE', 'reserved_identifier'),432 ('ks', 'identifier'),433 ('WITH', 'reserved_identifier'),434 ('REPLICATION', 'identifier'),435 ('=', 'op'),436 ('{', 'brackets'),437 ("'class'", 'quotedStringLiteral'),438 (':', 'colon'),439 ("'SimpleStrategy'", 'quotedStringLiteral'),440 (',', 'op'),441 ("'replication_factor'", 'quotedStringLiteral'),442 (':', 'colon'),443 ('1', 'wholenumber'),444 ('}', 'brackets'),445 (';', 'endtoken')])446 parsed = parse_cqlsh_statements(447 'CREATE KEYSPACE "Cql_test_KS" WITH REPLICATION = '448 "{'class': 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2': 2};")449 self.assertSequenceEqual(tokens_with_types(parsed),450 [('CREATE', 'reserved_identifier'),451 ('KEYSPACE', 'reserved_identifier'),452 ('"Cql_test_KS"', 'quotedName'),453 ('WITH', 'reserved_identifier'),454 ('REPLICATION', 'identifier'),455 ('=', 'op'),456 ('{', 'brackets'),457 ("'class'", 'quotedStringLiteral'),458 (':', 'colon'),459 ("'NetworkTopologyStrategy'",460 'quotedStringLiteral'),461 (',', 'op'),462 ("'dc1'", 'quotedStringLiteral'),463 (':', 'colon'),464 ('3', 'wholenumber'),465 (',', 'op'),466 ("'dc2'", 'quotedStringLiteral'),467 (':', 'colon'),468 ('2', 'wholenumber'),469 ('}', 'brackets'),470 (';', 'endtoken')])471 parsed = parse_cqlsh_statements(472 "CREATE KEYSPACE ks WITH REPLICATION = "473 "{'class': 'NetworkTopologyStrategy', 'dc1': 3} AND "474 "DURABLE_WRITES = false;")475 self.assertSequenceEqual(tokens_with_types(parsed),476 [('CREATE', 'reserved_identifier'),477 ('KEYSPACE', 'reserved_identifier'),478 ('ks', 'identifier'),479 ('WITH', 'reserved_identifier'),480 ('REPLICATION', 'identifier'),481 ('=', 'op'),482 ('{', 'brackets'),483 ("'class'", 'quotedStringLiteral'),484 (':', 'colon'),485 ("'NetworkTopologyStrategy'",486 'quotedStringLiteral'),487 (',', 'op'),488 ("'dc1'", 'quotedStringLiteral'),489 (':', 'colon'),490 ('3', 'wholenumber'),491 ('}', 'brackets'),492 ('AND', 'reserved_identifier'),493 # 'DURABLE_WRITES' is not a keyword494 ('DURABLE_WRITES', 'identifier'),495 ('=', 'op'),496 ('false', 'identifier'),497 (';', 'endtoken')])498 def test_parse_drop_keyspace(self):499 parsed = parse_cqlsh_statements(500 'DROP KEYSPACE ks;')501 self.assertSequenceEqual(tokens_with_types(parsed),502 [('DROP', 'reserved_identifier'),503 ('KEYSPACE', 'reserved_identifier'),504 ('ks', 'identifier'),505 (';', 'endtoken')])506 parsed = parse_cqlsh_statements(507 'DROP SCHEMA ks;')508 self.assertSequenceEqual(tokens_with_types(parsed),509 [('DROP', 'reserved_identifier'),510 ('SCHEMA', 'reserved_identifier'),511 ('ks', 'identifier'),512 (';', 'endtoken')])513 parsed = parse_cqlsh_statements(514 'DROP KEYSPACE IF EXISTS "My_ks";')515 self.assertSequenceEqual(tokens_with_types(parsed),516 [('DROP', 'reserved_identifier'),517 ('KEYSPACE', 'reserved_identifier'),518 ('IF', 'reserved_identifier'),519 ('EXISTS', 'identifier'),520 ('"My_ks"', 'quotedName'),521 (';', 'endtoken')])522 def test_parse_create_table(self):523 pass524 def test_parse_drop_table(self):525 pass526 def test_parse_truncate(self):527 pass528 def test_parse_alter_table(self):529 pass530 def test_parse_use(self):531 pass532 def test_parse_create_index(self):533 parsed = parse_cqlsh_statements(534 'CREATE INDEX idx ON ks.tab (i);')535 self.assertSequenceEqual(tokens_with_types(parsed),536 (('CREATE', 'reserved_identifier'),537 ('INDEX', 'reserved_identifier'),538 ('idx', 'identifier'),539 ('ON', 'reserved_identifier'),540 ('ks', 'identifier'),541 ('.', 'op'),542 ('tab', 'identifier'),543 ('(', 'op'),544 ('i', 'identifier'),545 (')', 'op'),546 (';', 'endtoken')))547 parsed = parse_cqlsh_statements(548 'CREATE INDEX idx ON ks.tab (i) IF NOT EXISTS;')549 self.assertSequenceEqual(tokens_with_types(parsed),550 (('CREATE', 'reserved_identifier'),551 ('INDEX', 'reserved_identifier'),552 ('idx', 'identifier'),553 ('ON', 'reserved_identifier'),554 ('ks', 'identifier'),555 ('.', 'op'),556 ('tab', 'identifier'),557 ('(', 'op'),558 ('i', 'identifier'),559 (')', 'op'),560 ('IF', 'reserved_identifier'),561 ('NOT', 'reserved_identifier'),562 ('EXISTS', 'identifier'),563 (';', 'endtoken')))564 parsed = parse_cqlsh_statements(565 'CREATE INDEX idx ON tab (KEYS(i));')566 self.assertSequenceEqual(tokens_with_types(parsed),567 (('CREATE', 'reserved_identifier'),568 ('INDEX', 'reserved_identifier'),569 ('idx', 'identifier'),570 ('ON', 'reserved_identifier'),571 ('tab', 'identifier'),572 ('(', 'op'),573 ('KEYS', 'identifier'),574 ('(', 'op'),575 ('i', 'identifier'),576 (')', 'op'),577 (')', 'op'),578 (';', 'endtoken')))579 parsed = parse_cqlsh_statements(580 'CREATE INDEX idx ON ks.tab FULL(i);')581 self.assertSequenceEqual(tokens_with_types(parsed),582 [('CREATE', 'reserved_identifier'),583 ('INDEX', 'reserved_identifier'),584 ('idx', 'identifier'),585 ('ON', 'reserved_identifier'),586 ('ks', 'identifier'),587 ('.', 'op'),588 ('tab', 'identifier'),589 ('FULL', 'reserved_identifier'),590 ('(', 'op'),591 ('i', 'identifier'),592 (')', 'op'),593 (';', 'endtoken')])594 parsed = parse_cqlsh_statements(595 'CREATE CUSTOM INDEX idx ON ks.tab (i);')596 self.assertSequenceEqual(tokens_with_types(parsed),597 [('CREATE', 'reserved_identifier'),598 ('CUSTOM', 'identifier'),599 ('INDEX', 'reserved_identifier'),600 ('idx', 'identifier'),601 ('ON', 'reserved_identifier'),602 ('ks', 'identifier'),603 ('.', 'op'),604 ('tab', 'identifier'),605 ('(', 'op'),606 ('i', 'identifier'),607 (')', 'op'),608 (';', 'endtoken')])609 parsed = parse_cqlsh_statements(610 "CREATE INDEX idx ON ks.tab (i) USING "611 "'org.custom.index.MyIndexClass';")612 self.assertSequenceEqual(tokens_with_types(parsed),613 [('CREATE', 'reserved_identifier'),614 ('INDEX', 'reserved_identifier'),615 ('idx', 'identifier'),616 ('ON', 'reserved_identifier'),617 ('ks', 'identifier'),618 ('.', 'op'),619 ('tab', 'identifier'),620 ('(', 'op'),621 ('i', 'identifier'),622 (')', 'op'),623 ('USING', 'reserved_identifier'),624 ("'org.custom.index.MyIndexClass'",625 'quotedStringLiteral'),626 (';', 'endtoken')])627 parsed = parse_cqlsh_statements(628 "CREATE INDEX idx ON ks.tab (i) WITH OPTIONS = "629 "{'storage': '/mnt/ssd/indexes/'};")630 self.assertSequenceEqual(tokens_with_types(parsed),631 [('CREATE', 'reserved_identifier'),632 ('INDEX', 'reserved_identifier'),633 ('idx', 'identifier'),634 ('ON', 'reserved_identifier'),635 ('ks', 'identifier'),636 ('.', 'op'),637 ('tab', 'identifier'),638 ('(', 'op'),639 ('i', 'identifier'),640 (')', 'op'),641 ('WITH', 'reserved_identifier'),642 ('OPTIONS', 'identifier'),643 ('=', 'op'),644 ('{', 'brackets'),...

Full Screen

Full Screen

test_series.py

Source:test_series.py Github

copy

Full Screen

...8 ('bar', 2),9 ('baz', 3)10 ]11 series = leather.Series(data)12 self.assertSequenceEqual(series.values(X), ['foo', 'bar', 'baz'])13 self.assertSequenceEqual(series.values(Y), [1, 2, 3])14 def test_lists(self):15 data = [16 ('foo', 1, 4),17 ('bar', 2, 5),18 ('baz', 3, 6)19 ]20 series = leather.Series(data)21 self.assertSequenceEqual(series.values(X), ['foo', 'bar', 'baz'])22 self.assertSequenceEqual(series.values(Y), [1, 2, 3])23 series = leather.Series(data, x=2, y=0)24 self.assertSequenceEqual(series.values(X), [4, 5, 6])25 self.assertSequenceEqual(series.values(Y), ['foo', 'bar', 'baz'])26 with self.assertRaises(TypeError):27 series = leather.Series(data, x='words')28 def test_dicts(self):29 data = [30 {'a': 'foo', 'b': 1, 'c': 4},31 {'a': 'bar', 'b': 2, 'c': 5},32 {'a': 'baz', 'b': 3, 'c': 6}33 ]34 with self.assertRaises(KeyError):35 series = leather.Series(data)36 series = leather.Series(data, x='c', y='a')37 self.assertSequenceEqual(series.values(X), [4, 5, 6])38 self.assertSequenceEqual(series.values(Y), ['foo', 'bar', 'baz'])39 def test_custom(self):40 class Obj(object):41 def __init__(self, a, b, c):42 self.a = a43 self.b = b44 self.c =c45 data = [46 Obj('foo', 1, 4),47 Obj('bar', 2, 5),48 Obj('baz', 3, 6)49 ]50 with self.assertRaises(TypeError):51 series = leather.Series(data)52 with self.assertRaises(TypeError):53 series = leather.Series(data, x='words', y='more')54 def get_x(row, i):55 return row.b56 def get_y(row, i):57 return row.c58 series = leather.Series(data, x=get_x, y=get_y)59 self.assertSequenceEqual(series.values(X), [1, 2, 3])60 self.assertSequenceEqual(series.values(Y), [4, 5, 6])61class TestCategorySeries(leather.LeatherTestCase):62 def test_triples(self):63 data = [64 ('foo', 1, 'a'),65 ('bar', 2, 'a'),66 ('baz', 3, 'b')67 ]68 series = leather.CategorySeries(data)69 self.assertSequenceEqual(series.values(X), ['foo', 'bar', 'baz'])70 self.assertSequenceEqual(series.values(Y), [1, 2, 3])...

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