-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
154 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "readmeai" | ||
version = "0.4.056" | ||
version = "0.4.057" | ||
description = "🚀 Generate beautiful README files from the terminal, powered by OpenAI's GPT language models 💫" | ||
authors = ["Eli <[email protected]>"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
"""Pytest configuration file.""" | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
import toml | ||
|
||
from readmeai.config.settings import AppConfigModel, ConfigHelper, load_config | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def config(): | ||
current_dir = Path(__file__).parent | ||
parent_dir = current_dir.parent | ||
config_path = parent_dir / "settings/config.toml" | ||
config_dict = load_config() | ||
config_model = AppConfigModel(app=config_dict) | ||
return config_model | ||
|
||
with open(config_path, "r") as file: | ||
config = toml.load(file) | ||
|
||
return config | ||
@pytest.fixture(scope="session") | ||
def config_helper(config): | ||
return ConfigHelper(config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"""Unit tests for utils.py.""" | ||
|
||
from pathlib import Path | ||
|
||
from readmeai.config.settings import ConfigHelper | ||
from readmeai.utils.utils import ( | ||
flatten_list, | ||
format_sentence, | ||
get_relative_path, | ||
is_valid_url, | ||
remove_substring, | ||
should_ignore, | ||
) | ||
|
||
|
||
def test_is_valid_url(): | ||
assert is_valid_url("https://www.example.com") is True | ||
assert is_valid_url("http://www.example.com") is True | ||
assert is_valid_url("www.example.com") is False | ||
assert is_valid_url("example.com") is False | ||
|
||
|
||
def test_flatten_list(): | ||
nested_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | ||
flattened_list = flatten_list(nested_list) | ||
assert flattened_list == [1, 2, 3, 4, 5, 6, 7, 8, 9] | ||
|
||
|
||
def test_format_sentence(): | ||
text = "'hello world'" | ||
formatted_sentence = format_sentence(text) | ||
assert formatted_sentence == "hello world" | ||
|
||
|
||
def test_get_relative_path(): | ||
"""Test that the relative path is correct.""" | ||
absolute_path = "readmeai/utils/utils.py" | ||
base_path = Path().parent | ||
relative_path = get_relative_path(absolute_path, base_path) | ||
assert str(relative_path) == "readmeai/utils/utils.py" | ||
|
||
|
||
def test_remove_substring(): | ||
"""Test that the substring is removed from the input string.""" | ||
test_string = """ | ||
<div> | ||
<p>Paragraph 1 content.</p> | ||
Some content that should remain. | ||
<p>Paragraph 2 content with <div> nested tag.</p></div> | ||
This content is outside of the div tags. | ||
<p>Another paragraph.</p> | ||
<div>Content to be removed.</div> | ||
<p>Final paragraph.</p> | ||
<div> | ||
<p>Paragraph inside div.</p> | ||
Content inside div that should be removed. | ||
</div> | ||
</div> | ||
""" | ||
result = remove_substring(test_string) | ||
assert isinstance(result, str) | ||
|
||
|
||
def test_should_ignore(config_helper: ConfigHelper): | ||
"""Test that the file is ignored.""" | ||
file_path_ignored = Path("README.md") | ||
file_path_not_ignored = Path("readmeai/main.py") | ||
assert should_ignore(config_helper, file_path_ignored) is True | ||
assert should_ignore(config_helper, file_path_not_ignored) is False |