move script to module

This commit is contained in:
Bhupesh Varshney 2023-02-09 11:39:22 +00:00
parent 9f78c6f611
commit f5ec4f6592
6 changed files with 7 additions and 4 deletions

View File

@ -29,10 +29,14 @@ jobs:
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install flake8 pytest pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test Community IDCard Update
run: |
cd idcard_update
python -m unittest
- name: Change Titles - name: Change Titles
env: env:
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }} REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }} REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }}
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }} REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }}
run: | run: |
python main.py python idcard_update/main.py

View File

@ -9,7 +9,7 @@
## Scripts ## Scripts
### [main.py](https://github.com/developersIndia/deviras/blob/main/main.py) ### [idcard_update](https://github.com/developersIndia/deviras/blob/idcard_update)
Used for changing the text below total members & live members count in a subreddit. Used for changing the text below total members & live members count in a subreddit.

View File

View File

@ -1,5 +1,6 @@
import unittest import unittest
from unittest.mock import patch from unittest.mock import patch
from main import get_titles
# patch out the environ dictionary # patch out the environ dictionary
# used to instantiate global variables in the titles_updater script # used to instantiate global variables in the titles_updater script
@ -11,8 +12,6 @@ environ_patcher = patch.dict('os.environ', {
}) })
environ_patcher.start() environ_patcher.start()
from main import get_titles
class TestGetTitles(unittest.TestCase): class TestGetTitles(unittest.TestCase):
@patch('main.json.load', return_value={'titles': ['foo', 'bar', 'baz']}) @patch('main.json.load', return_value={'titles': ['foo', 'bar', 'baz']})
def test_get_titles_returns_a_list(self, _): def test_get_titles_returns_a_list(self, _):