File: segments_raw_test.py

package info (click to toggle)
sqlfluff 3.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,000 kB
  • sloc: python: 106,131; sql: 34,188; makefile: 52; sh: 8
file content (30 lines) | stat: -rw-r--r-- 966 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Test the RawSegment class."""

from sqlfluff.core.parser.segments.base import PathStep


def test__parser__raw_get_raw_segments(raw_segments):
    """Test niche case of calling get_raw_segments on a raw segment."""
    for s in raw_segments:
        assert s.get_raw_segments() == [s]


def test__parser__raw_segments_with_ancestors(
    raw_segments, DummySegment, DummyAuxSegment
):
    """Test raw_segments_with_ancestors.

    This is used in the reflow module to assess parse depth.
    """
    test_seg = DummySegment([DummyAuxSegment(raw_segments[:1]), raw_segments[1]])
    # Result should be the same raw segment, but with appropriate parents
    assert test_seg.raw_segments_with_ancestors == [
        (
            raw_segments[0],
            [
                PathStep(test_seg, 0, 2, (0, 1)),
                PathStep(test_seg.segments[0], 0, 1, (0,)),
            ],
        ),
        (raw_segments[1], [PathStep(test_seg, 1, 2, (0, 1))]),
    ]