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:
Cursor Agent
2026-08-04 16:36:44 +00:00
parent 965fdb36e4
commit 7bb690dad0

View File

@@ -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
)