Skip to content

Commit 84b7f95

Browse files
committed
fix(tests): correct patch paths for create_post and create_text_post
Resolved AttributeError in test_main.py by updating mock.patch targets to use the correct module path (src.app.* instead of main.app.*). This ensures that create_post and create_text_post are properly mocked during CLI command tests. * modified: tests/test_main.py Signed-off-by: Muhammad Amin Boubaker <muhammadaminboubaker@gmail.com>
1 parent 446e148 commit 84b7f95

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/test_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_get_recent_posts(self):
4949
self.assertIn("Recent Posts", result.stdout)
5050

5151
def test_create_text_post(self):
52-
with patch("main.app.create_post") as mock_create_post:
52+
with patch("src.app.create_post") as mock_create_post:
5353
mock_create_post.return_value = {"id": "123"}
5454
result = self.runner.invoke(app, ["create-text-post", "Test post"])
5555
self.assertEqual(result.exit_code, 0)
@@ -79,7 +79,7 @@ def test_send_draft(self):
7979
draft_id = drafts[0]["id"]
8080

8181
# Test sending an existing draft
82-
with patch("main.app.create_text_post") as mock_create_text_post:
82+
with patch("src.app.create_text_post") as mock_create_text_post:
8383
result = self.runner.invoke(app, ["send-draft", str(draft_id), "--drafts-file", TEST_DRAFTS_FILE])
8484
self.assertEqual(result.exit_code, 0)
8585
self.assertIn(f"Draft with ID {draft_id} sent and removed from drafts.", result.stdout)

0 commit comments

Comments
 (0)