Commit 482ef94
committed
Fix: Prevent test failures due to missing ACCESS_TOKEN
The test suite was failing because the application would exit prematurely when the ACCESS_TOKEN environment variable was not set during test execution.
This commit addresses the issue by:
- Patching `sys.exit` in the `TestThreadsCLI` setup to prevent the application from exiting.
- Adding basic mocking for API calls in `test_get_profile` and `test_get_recent_posts` to allow these tests to run without a valid ACCESS_TOKEN.
- Ensuring the test drafts file is removed before each test run to maintain a clean state.
This resolves the `AssertionError: 1 != 0` seen in tests like `test_get_profile`, `test_get_recent_posts`, and `test_create_text_post` when running in environments without the ACCESS_TOKEN configured.
* modified: tests/test_main.py
Signed-off-by: Muhammad Amin Boubaker <muhammadaminboubaker@gmail.com>1 parent 84b7f95 commit 482ef94
1 file changed
+28
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
36 | 44 | | |
37 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
38 | 49 | | |
39 | 50 | | |
40 | 51 | | |
41 | 52 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
45 | 60 | | |
46 | 61 | | |
47 | | - | |
48 | | - | |
49 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
50 | 70 | | |
51 | 71 | | |
52 | 72 | | |
| |||
94 | 114 | | |
95 | 115 | | |
96 | 116 | | |
| 117 | + | |
0 commit comments