Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillweston committed Apr 23, 2024
1 parent 429e40c commit fb49d0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ Replace `<user_id>` with the numeric user ID of the Twitter account you want to
- **Secure Authentication**: Uses environment variables to securely manage the Bearer Token.
- **Flexible**: Easily change the Twitter user you are monitoring by passing a different user ID as a command-line argument.

## How to test the script

Run the following command to use pytest to test the script:

```bash
py -m pytest py_test.py
```

## Contributing

Contributions are welcome! Please feel free to submit pull requests or create issues if you have suggestions or encounter bugs.
Expand Down
10 changes: 3 additions & 7 deletions py_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import pytest
from unittest.mock import Mock, patch, mock_open
from stream_listener import fetch_tweets, get_user_id
import datetime
import re
import unittest
from freezegun import freeze_time

author_name = 'LotsoFandom'
Expand All @@ -16,7 +12,7 @@ def test_get_user_id():
mocked_client.get_user.return_value = Mock(data=Mock(id=author_id))
user_id = get_user_id(author_name)
assert user_id == author_id
mocked_client.get_user.assert_called_once_with(username='LotsoFandom')
mocked_client.get_user.assert_called_once_with(username=author_name)

# Test for fetch_tweets function
@freeze_time("2023-04-23 01:01:01")
Expand Down Expand Up @@ -48,8 +44,8 @@ def test_fetch_tweets():

# Check the content written to the file
mocked_file().write.assert_called_once_with(
"## Tweet by 1742141344787857408\n\n"
"**Tweet ID:** 1777555856705667262\n"
f"## Tweet by {author_id}\n\n"
f"**Tweet ID:** {tweet_id}\n"
"**Created at:** 2023-01-01\n"
"**Text:**\n\n"
"Sample Tweet\n"
Expand Down

0 comments on commit fb49d0a

Please sign in to comment.