diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 2383cee..f045e42 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -26,7 +26,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest + pip install flake8 pytest -e . if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | diff --git a/setup.py b/setup.py index 25a399f..17ad84b 100644 --- a/setup.py +++ b/setup.py @@ -51,6 +51,10 @@ "requests_oauthlib==2.0.0", "ipdb", "ipython", + "coverage", + "pytest", + "pytest-asyncio", + "pytz", ], classifiers=[ "Development Status :: 3 - Alpha", diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_tweet_bot.py b/tests/test_tweet_bot.py new file mode 100644 index 0000000..2af17f6 --- /dev/null +++ b/tests/test_tweet_bot.py @@ -0,0 +1,15 @@ +import time +from pathlib import Path +from unittest.mock import patch, MagicMock + +from taogod_terminal.tweet_bot import parse_args, TWEET_FREQ + + +def test_parse_args(): + with patch("argparse.ArgumentParser.parse_args", return_value=MagicMock(tweets=Path("tweets.json"))): + args = parse_args() + assert args.tweets == Path("tweets.json") + +def test_tweet_frequency_logic(): + last_post_time = time.time() - TWEET_FREQ.total_seconds() - 1 + assert time.time() - last_post_time > TWEET_FREQ.total_seconds()