From 0c379d1a06f6ba46589791f8861aeb83df952ae4 Mon Sep 17 00:00:00 2001 From: kamlesh0928 Date: Wed, 23 Sep 2026 20:54:39 +0530 Subject: [PATCH 1/2] Commented few codes related to post on X --- app/agents/orchestrator.py | 13 ++++++----- tests/agents/test_orchestrator.py | 38 ++++++++++++++++--------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/app/agents/orchestrator.py b/app/agents/orchestrator.py index 0a6bd46..d990cb6 100644 --- a/app/agents/orchestrator.py +++ b/app/agents/orchestrator.py @@ -4,8 +4,8 @@ from app.discovery.repository import mark_topic_status from app.publishers.linkedin import LinkedInPublishError from app.publishers.linkedin import publish_post as publish_linkedin_post -from app.publishers.x import XPublishError -from app.publishers.x import publish_post as publish_x_post + +# from app.publishers.x import XPublishError # Uncomment - If added credits on X platform. from app.utils.logger import setup_logger logger = setup_logger("orchestrator") @@ -32,10 +32,11 @@ async def run_pipeline() -> None: except LinkedInPublishError: logger.exception("Failed to publish to LinkedIn for topic '%s'", topic.title) - try: - publish_x_post(approved.x_content) - except XPublishError: - logger.exception("Failed to publish to X for topic '%s'", topic.title) + # Uncomment - If added credits on X platform. + # try: + # publish_x_post(approved.x_content) + # except XPublishError: + # logger.exception("Failed to publish to X for topic '%s'", topic.title) return diff --git a/tests/agents/test_orchestrator.py b/tests/agents/test_orchestrator.py index 2ff6fd3..ee7e47a 100644 --- a/tests/agents/test_orchestrator.py +++ b/tests/agents/test_orchestrator.py @@ -3,7 +3,8 @@ from app.agents import orchestrator from app.database.models.topic import STATUS_REJECTED, STATUS_USED from app.publishers.linkedin import LinkedInPublishError -from app.publishers.x import XPublishError + +# from app.publishers.x import XPublishError # Uncomment - If added credits on X platform. class _FakeTopic: @@ -16,19 +17,19 @@ def __init__(self, id, title="Idea", rank=1): @pytest.mark.asyncio async def test_run_pipeline_stops_on_first_accepted_topic(mocker): topics = [_FakeTopic(id=1), _FakeTopic(id=2)] - approved = mocker.Mock(linkedin_content="Fake LinkedIn content", x_content="Fake X content") + approved = mocker.Mock(linkedin_content="Fake LinkedIn content") # Uncomment - If added credits on X platform. Add {x_content="Fake X content"} in the Mock parameter mocker.patch("app.agents.orchestrator.get_topics", return_value=topics) mock_generate_post = mocker.patch("app.agents.orchestrator.generate_post", side_effect=[approved]) mock_mark_status = mocker.patch("app.agents.orchestrator.mark_topic_status") mock_publish_linkedin = mocker.patch("app.agents.orchestrator.publish_linkedin_post") - mock_publish_x = mocker.patch("app.agents.orchestrator.publish_x_post") + # mock_publish_x = mocker.patch("app.agents.orchestrator.publish_x_post") # Uncomment - If added credits on X platform. await orchestrator.run_pipeline() mock_generate_post.assert_awaited_once_with(topics[0]) mock_mark_status.assert_called_once_with(1, STATUS_USED) mock_publish_linkedin.assert_called_once_with("Fake LinkedIn content") - mock_publish_x.assert_called_once_with("Fake X content") + # mock_publish_x.assert_called_once_with("Fake X content") # Uncomment - If added credits on X platform. @pytest.mark.asyncio @@ -60,7 +61,7 @@ async def test_run_pipeline_regenerates_when_all_topics_rejected(mocker): mocker.patch("app.agents.orchestrator.generate_post", side_effect=[None, approved]) mocker.patch("app.agents.orchestrator.mark_topic_status") mocker.patch("app.agents.orchestrator.publish_linkedin_post") - mocker.patch("app.agents.orchestrator.publish_x_post") + # mocker.patch("app.agents.orchestrator.publish_x_post") # Uncomment - If added credits on X platform. await orchestrator.run_pipeline() @@ -75,27 +76,28 @@ async def test_run_pipeline_logs_and_continues_when_linkedin_publish_fails(mocke mocker.patch("app.agents.orchestrator.generate_post", side_effect=[approved]) mock_mark_status = mocker.patch("app.agents.orchestrator.mark_topic_status") mocker.patch("app.agents.orchestrator.publish_linkedin_post", side_effect=LinkedInPublishError("boom")) - mock_publish_x = mocker.patch("app.agents.orchestrator.publish_x_post") + # mock_publish_x = mocker.patch("app.agents.orchestrator.publish_x_post") # Uncomment - If added credits on X platform. await orchestrator.run_pipeline() mock_mark_status.assert_called_once_with(1, STATUS_USED) - mock_publish_x.assert_called_once_with("Fake X content") + # mock_publish_x.assert_called_once_with("Fake X content") # Uncomment - If added credits on X platform. -@pytest.mark.asyncio -async def test_run_pipeline_logs_and_continues_when_x_publish_fails(mocker): - topics = [_FakeTopic(id=1)] - approved = mocker.Mock(linkedin_content="Fake LinkedIn content", x_content="Fake X content") - mocker.patch("app.agents.orchestrator.get_topics", return_value=topics) - mocker.patch("app.agents.orchestrator.generate_post", side_effect=[approved]) - mock_mark_status = mocker.patch("app.agents.orchestrator.mark_topic_status") - mocker.patch("app.agents.orchestrator.publish_linkedin_post") - mocker.patch("app.agents.orchestrator.publish_x_post", side_effect=XPublishError("boom")) +# Uncomment - If added credits on X platform. +# @pytest.mark.asyncio +# async def test_run_pipeline_logs_and_continues_when_x_publish_fails(mocker): +# topics = [_FakeTopic(id=1)] +# approved = mocker.Mock(linkedin_content="Fake LinkedIn content", x_content="Fake X content") +# mocker.patch("app.agents.orchestrator.get_topics", return_value=topics) +# mocker.patch("app.agents.orchestrator.generate_post", side_effect=[approved]) +# mock_mark_status = mocker.patch("app.agents.orchestrator.mark_topic_status") +# mocker.patch("app.agents.orchestrator.publish_linkedin_post") +# mocker.patch("app.agents.orchestrator.publish_x_post", side_effect=XPublishError("boom")) - await orchestrator.run_pipeline() +# await orchestrator.run_pipeline() - mock_mark_status.assert_called_once_with(1, STATUS_USED) +# mock_mark_status.assert_called_once_with(1, STATUS_USED) @pytest.mark.asyncio From 1374a3e2d7a44051165053adf0060239fd34e969 Mon Sep 17 00:00:00 2001 From: kamlesh0928 Date: Wed, 23 Sep 2026 21:05:14 +0530 Subject: [PATCH 2/2] Corrected the python testcases --- tests/agents/test_orchestrator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/agents/test_orchestrator.py b/tests/agents/test_orchestrator.py index ee7e47a..6a64ebc 100644 --- a/tests/agents/test_orchestrator.py +++ b/tests/agents/test_orchestrator.py @@ -35,12 +35,12 @@ async def test_run_pipeline_stops_on_first_accepted_topic(mocker): @pytest.mark.asyncio async def test_run_pipeline_tries_next_topic_after_rejection(mocker): topics = [_FakeTopic(id=1), _FakeTopic(id=2)] - approved = mocker.Mock(linkedin_content="Fake LinkedIn content", x_content="Fake X content") + approved = mocker.Mock(linkedin_content="Fake LinkedIn content") # Uncomment - If added credits on X platform. Add {x_content="Fake X content"} in the Mock parameter mocker.patch("app.agents.orchestrator.get_topics", return_value=topics) mocker.patch("app.agents.orchestrator.generate_post", side_effect=[None, approved]) mock_mark_status = mocker.patch("app.agents.orchestrator.mark_topic_status") mocker.patch("app.agents.orchestrator.publish_linkedin_post") - mocker.patch("app.agents.orchestrator.publish_x_post") + # mocker.patch("app.agents.orchestrator.publish_x_post") # Uncomment - If added credits on X platform. await orchestrator.run_pipeline() @@ -54,7 +54,7 @@ async def test_run_pipeline_tries_next_topic_after_rejection(mocker): async def test_run_pipeline_regenerates_when_all_topics_rejected(mocker): first_batch = [_FakeTopic(id=1)] second_batch = [_FakeTopic(id=2)] - approved = mocker.Mock(linkedin_content="Fake LinkedIn content", x_content="Fake X content") + approved = mocker.Mock(linkedin_content="Fake LinkedIn content") # Uncomment - If added credits on X platform. Add {x_content="Fake X content"} in the Mock parameter mock_get_topics = mocker.patch( "app.agents.orchestrator.get_topics", side_effect=[first_batch, second_batch] ) @@ -71,7 +71,7 @@ async def test_run_pipeline_regenerates_when_all_topics_rejected(mocker): @pytest.mark.asyncio async def test_run_pipeline_logs_and_continues_when_linkedin_publish_fails(mocker): topics = [_FakeTopic(id=1)] - approved = mocker.Mock(linkedin_content="Fake LinkedIn content", x_content="Fake X content") + approved = mocker.Mock(linkedin_content="Fake LinkedIn content") # Uncomment - If added credits on X platform. Add {x_content="Fake X content"} in the Mock parameter mocker.patch("app.agents.orchestrator.get_topics", return_value=topics) mocker.patch("app.agents.orchestrator.generate_post", side_effect=[approved]) mock_mark_status = mocker.patch("app.agents.orchestrator.mark_topic_status")