|
30 | 30 | UserType, KeyspaceMetadata, get_schema_parser, |
31 | 31 | _UnknownStrategy, ColumnMetadata, TableMetadata, |
32 | 32 | IndexMetadata, Function, Aggregate, |
33 | | - Metadata, TokenMap, ReplicationFactor) |
| 33 | + Metadata, TokenMap, ReplicationFactor, |
| 34 | + SchemaParserDSE68) |
34 | 35 | from cassandra.policies import SimpleConvictionPolicy |
35 | 36 | from cassandra.pool import Host |
| 37 | +from cassandra.protocol import QueryMessage |
36 | 38 | from tests.util import assertCountEqual |
37 | 39 | import pytest |
38 | 40 |
|
@@ -616,6 +618,37 @@ def test_build_index_as_cql(self): |
616 | 618 | assert index_meta.as_cql_query() == "CREATE CUSTOM INDEX index_name_here ON keyspace_name_here.table_name_here (column_name_here) USING 'class_name_here'" |
617 | 619 |
|
618 | 620 |
|
| 621 | +class SchemaParserLookupTests(unittest.TestCase): |
| 622 | + |
| 623 | + def test_reads_versions_from_system_local_when_missing(self): |
| 624 | + connection = Mock() |
| 625 | + |
| 626 | + release_version_resp = Mock() |
| 627 | + release_version_resp.column_names = ["release_version"] |
| 628 | + release_version_resp.parsed_rows = [["4.0.0"]] |
| 629 | + |
| 630 | + dse_version_resp = Mock() |
| 631 | + dse_version_resp.column_names = ["dse_version"] |
| 632 | + dse_version_resp.parsed_rows = [["6.8.0"]] |
| 633 | + |
| 634 | + def mock_system_local(query, *args, **kwargs): |
| 635 | + if not isinstance(query, QueryMessage): |
| 636 | + raise RuntimeError("first argument should be a QueryMessage") |
| 637 | + if "release_version" in query.query: |
| 638 | + return (True, release_version_resp) |
| 639 | + if "dse_version" in query.query: |
| 640 | + return (True, dse_version_resp) |
| 641 | + raise RuntimeError("unexpected query") |
| 642 | + |
| 643 | + connection.wait_for_response.side_effect = mock_system_local |
| 644 | + |
| 645 | + parser = get_schema_parser(connection, None, None, 0.1, None) |
| 646 | + |
| 647 | + assert isinstance(parser, SchemaParserDSE68) |
| 648 | + message = connection.wait_for_response.call_args[0][0] |
| 649 | + assert "system.local" in message.query |
| 650 | + |
| 651 | + |
619 | 652 | class UnicodeIdentifiersTests(unittest.TestCase): |
620 | 653 | """ |
621 | 654 | Exercise cql generation with unicode characters. Keyspace, Table, and Index names |
|
0 commit comments