mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-08-10 08:21:54 +00:00
test: call DataTypes.from_content in GitHub hostname tests
from_content lives on DataTypes, not the DataType enum. Co-authored-by: Rip&Tear <theCyberTech@users.noreply.github.com>
This commit is contained in:
@@ -1,32 +1,32 @@
|
||||
"""Tests for DataType content classification."""
|
||||
"""Tests for DataTypes content classification."""
|
||||
|
||||
from crewai_tools.rag.data_types import DataType
|
||||
from crewai_tools.rag.data_types import DataType, DataTypes
|
||||
|
||||
|
||||
class TestDataTypeFromContentGitHub:
|
||||
class TestDataTypesFromContentGitHub:
|
||||
"""GitHub URL detection must use hostname matching, not substrings."""
|
||||
|
||||
def test_github_com_url(self) -> None:
|
||||
assert (
|
||||
DataType.from_content("https://github.com/crewai/crewai")
|
||||
DataTypes.from_content("https://github.com/crewai/crewai")
|
||||
== DataType.GITHUB
|
||||
)
|
||||
|
||||
def test_github_subdomain_url(self) -> None:
|
||||
assert (
|
||||
DataType.from_content("https://gist.github.com/user/abc")
|
||||
DataTypes.from_content("https://gist.github.com/user/abc")
|
||||
== DataType.GITHUB
|
||||
)
|
||||
|
||||
def test_spoofed_github_hostname_is_website(self) -> None:
|
||||
# Substring checks like `"github.com" in netloc` would misclassify this.
|
||||
assert (
|
||||
DataType.from_content("https://github.com.evil.example/crewai")
|
||||
DataTypes.from_content("https://github.com.evil.example/crewai")
|
||||
== DataType.WEBSITE
|
||||
)
|
||||
|
||||
def test_github_in_path_is_not_github(self) -> None:
|
||||
assert (
|
||||
DataType.from_content("https://example.com/github.com/repo")
|
||||
DataTypes.from_content("https://example.com/github.com/repo")
|
||||
== DataType.WEBSITE
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user