Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 33 additions & 37 deletions src/kurt/tools/fetch/tests/test_cli_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ class TestFetchApifyEngine:
def test_fetch_apify_engine_option(self, cli_runner: CliRunner, tmp_project: Path):
"""Verify --engine apify is accepted and stores content."""
from kurt.db import managed_session
from kurt.tools.fetch.core import FetchResult
from kurt.tools.map.models import MapDocument, MapStatus

with managed_session() as session:
Expand All @@ -390,16 +389,16 @@ def test_fetch_apify_engine_option(self, cli_runner: CliRunner, tmp_project: Pat
session.add(doc)
session.commit()

# Mock apify fetcher
mock_result = FetchResult(
content="# Twitter Profile\n\nExample user profile content.",
metadata={"engine": "apify", "platform": "twitter"},
success=True,
)
with patch("kurt.tools.fetch.engines.apify.ApifyFetcher.fetch") as mock_fetch, \
patch("kurt.tools.fetch.engines.apify.ApifyClient"):
mock_fetch.return_value = mock_result
# Mock the apify engine in the _FETCH_ENGINES dictionary
async def mock_apify_fetch(*args, **kwargs):
return (
"# Twitter Profile\n\nExample user profile content.",
{"engine": "apify", "platform": "twitter"},
)

with patch.dict(
"kurt.tools.fetch.tool._FETCH_ENGINES", {"apify": mock_apify_fetch}
):
result = invoke_cli(
cli_runner,
fetch_cmd,
Expand All @@ -417,7 +416,6 @@ def test_fetch_apify_engine_option(self, cli_runner: CliRunner, tmp_project: Pat
def test_fetch_apify_with_platform(self, cli_runner: CliRunner, tmp_project: Path):
"""Verify --platform option works with apify engine."""
from kurt.db import managed_session
from kurt.tools.fetch.core import FetchResult
from kurt.tools.map.models import MapDocument, MapStatus

with managed_session() as session:
Expand All @@ -431,15 +429,15 @@ def test_fetch_apify_with_platform(self, cli_runner: CliRunner, tmp_project: Pat
session.add(doc)
session.commit()

mock_result = FetchResult(
content="# Twitter Content\n\nContent with platform option.",
metadata={"engine": "apify", "platform": "twitter"},
success=True,
)
with patch("kurt.tools.fetch.engines.apify.ApifyFetcher.fetch") as mock_fetch, \
patch("kurt.tools.fetch.engines.apify.ApifyClient"):
mock_fetch.return_value = mock_result
async def mock_apify_fetch(*args, **kwargs):
return (
"# Twitter Content\n\nContent with platform option.",
{"engine": "apify", "platform": "twitter"},
)

with patch.dict(
"kurt.tools.fetch.tool._FETCH_ENGINES", {"apify": mock_apify_fetch}
):
result = invoke_cli(
cli_runner,
fetch_cmd,
Expand All @@ -464,7 +462,6 @@ def test_fetch_apify_with_platform(self, cli_runner: CliRunner, tmp_project: Pat
def test_fetch_apify_with_actor(self, cli_runner: CliRunner, tmp_project: Path):
"""Verify --apify-actor option is accepted."""
from kurt.db import managed_session
from kurt.tools.fetch.core import FetchResult
from kurt.tools.map.models import MapDocument, MapStatus

with managed_session() as session:
Expand All @@ -478,15 +475,15 @@ def test_fetch_apify_with_actor(self, cli_runner: CliRunner, tmp_project: Path):
session.add(doc)
session.commit()

mock_result = FetchResult(
content="# Actor Content\n\nContent from custom actor.",
metadata={"engine": "apify"},
success=True,
)
with patch("kurt.tools.fetch.engines.apify.ApifyFetcher.fetch") as mock_fetch, \
patch("kurt.tools.fetch.engines.apify.ApifyClient"):
mock_fetch.return_value = mock_result
async def mock_apify_fetch(*args, **kwargs):
return (
"# Actor Content\n\nContent from custom actor.",
{"engine": "apify"},
)

with patch.dict(
"kurt.tools.fetch.tool._FETCH_ENGINES", {"apify": mock_apify_fetch}
):
result = invoke_cli(
cli_runner,
fetch_cmd,
Expand All @@ -513,7 +510,6 @@ def test_fetch_apify_with_content_type(
):
"""Verify --content-type option works with apify engine."""
from kurt.db import managed_session
from kurt.tools.fetch.core import FetchResult
from kurt.tools.map.models import MapDocument, MapStatus

with managed_session() as session:
Expand All @@ -527,15 +523,15 @@ def test_fetch_apify_with_content_type(
session.add(doc)
session.commit()

mock_result = FetchResult(
content="# Profile Content\n\nProfile-type content.",
metadata={"engine": "apify", "content_type": "profile"},
success=True,
)
with patch("kurt.tools.fetch.engines.apify.ApifyFetcher.fetch") as mock_fetch, \
patch("kurt.tools.fetch.engines.apify.ApifyClient"):
mock_fetch.return_value = mock_result
async def mock_apify_fetch(*args, **kwargs):
return (
"# Profile Content\n\nProfile-type content.",
{"engine": "apify", "content_type": "profile"},
)

with patch.dict(
"kurt.tools.fetch.tool._FETCH_ENGINES", {"apify": mock_apify_fetch}
):
result = invoke_cli(
cli_runner,
fetch_cmd,
Expand Down
4 changes: 1 addition & 3 deletions src/kurt/workflows/tests/test_cli_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,7 @@ def test_workflow_init_creates_directory(
# Should complete - creates example workflows
assert result.exit_code in (0, 1)

# Check if directory was created
tmp_project / ".kurt" / "workflows"
# May or may not exist depending on implementation
# Command completed - init creates example workflows in .kurt/workflows/


class TestWorkflowCreate:
Expand Down
Loading