Skip to content

Commit

Permalink
refactor: Rename a method in JinjaBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasyager committed Dec 29, 2023
1 parent 1d9008f commit 892dd65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions dbt_meshify/storage/jinja_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def find_block_range(file_content: str, block_type: str, name: str) -> Tuple[int
return start_line, end_line

@staticmethod
def isolate_content_from_line_range(file_content: str, start: int, end: int) -> str:
def isolate_content(file_content: str, start: int, end: int) -> str:
"""Given content, a start position, and an end position, return the content of a Jinja block."""
return file_content[start:end]

Expand All @@ -61,9 +61,7 @@ def from_file(cls, path: Path, block_type: str, name: str) -> "JinjaBlock":

file_content = open(path).read()
start, end = cls.find_block_range(file_content, block_type, name)
content = cls.isolate_content_from_line_range(
file_content=file_content, start=start, end=end
)
content = cls.isolate_content(file_content=file_content, start=start, end=end)

return cls(
path=path, block_type=block_type, name=name, start=start, end=end, content=content
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_jinja_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_from_file_detects_block_range(self):
assert range == (2, 72)

def test_from_file_extracts_content(self):
content = JinjaBlock.isolate_content_from_line_range(string, 2, 72)
content = JinjaBlock.isolate_content(string, 2, 72)
assert (
content == "{% docs customer_id %}\nThe unique key for each customer.\n{% enddocs %}"
)
Expand All @@ -37,7 +37,7 @@ def test_from_file_detects_block_range_in_multiple_blocks(self):
assert range == (74, 159)

def test_from_file_extracts_content_in_files_with_multiple_blocks(self):
content = JinjaBlock.isolate_content_from_line_range(multiple_blocks, 74, 159)
content = JinjaBlock.isolate_content(multiple_blocks, 74, 159)
assert (
content
== "{% docs potato_name %}\nThe name of the customer's favorite potato dish.\n{% enddocs %}"
Expand Down

0 comments on commit 892dd65

Please sign in to comment.