From f5ec4f65922b571e8018f501141eb2cf9037bbde Mon Sep 17 00:00:00 2001 From: Bhupesh Varshney Date: Thu, 9 Feb 2023 11:39:22 +0000 Subject: [PATCH] move script to module --- .github/workflows/python-app.yml | 6 +++++- README.md | 2 +- idcard_update/__init__.py | 0 dataset.json => idcard_update/dataset.json | 0 main.py => idcard_update/main.py | 0 test_get_titles.py => idcard_update/test_get_titles.py | 3 +-- 6 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 idcard_update/__init__.py rename dataset.json => idcard_update/dataset.json (100%) rename main.py => idcard_update/main.py (100%) rename test_get_titles.py => idcard_update/test_get_titles.py (99%) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 0fb7a27..417538b 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -29,10 +29,14 @@ jobs: python -m pip install --upgrade pip pip install flake8 pytest 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 env: REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }} REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }} REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }} run: | - python main.py + python idcard_update/main.py diff --git a/README.md b/README.md index 57f0abe..3e1ec9f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ## 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. diff --git a/idcard_update/__init__.py b/idcard_update/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataset.json b/idcard_update/dataset.json similarity index 100% rename from dataset.json rename to idcard_update/dataset.json diff --git a/main.py b/idcard_update/main.py similarity index 100% rename from main.py rename to idcard_update/main.py diff --git a/test_get_titles.py b/idcard_update/test_get_titles.py similarity index 99% rename from test_get_titles.py rename to idcard_update/test_get_titles.py index 89a417d..0130dbf 100644 --- a/test_get_titles.py +++ b/idcard_update/test_get_titles.py @@ -1,5 +1,6 @@ import unittest from unittest.mock import patch +from main import get_titles # patch out the environ dictionary # used to instantiate global variables in the titles_updater script @@ -11,8 +12,6 @@ environ_patcher = patch.dict('os.environ', { }) environ_patcher.start() -from main import get_titles - class TestGetTitles(unittest.TestCase): @patch('main.json.load', return_value={'titles': ['foo', 'bar', 'baz']}) def test_get_titles_returns_a_list(self, _):