Skip to content

Commit 7e6e919

Browse files
Merge pull request #5 from CoolCoderCarl/feature/TEST_1
Add testing with pytest
2 parents 838e7bc + 950d408 commit 7e6e919

7 files changed

Lines changed: 55 additions & 7 deletions

File tree

.github/workflows/build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ jobs:
6060
include:
6161
- os: windows-latest
6262
TARGET: windows
63-
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F truth_seeker.py
63+
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F ./app/truth_seeker.py
6464
OUT_FILE_NAME: truth_seeker.exe
6565
ASSET_MIME: application/vnd.microsoft.portable-executable
6666
- os: ubuntu-latest
6767
TARGET: ubuntu
68-
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F truth_seeker.py
68+
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F ./app/truth_seeker.py
6969
OUT_FILE_NAME: truth_seeker
7070
ASSET_MIME: application/x-binary
7171

@@ -124,7 +124,7 @@ jobs:
124124
125125
<b>WorkFlows:</b> <a href="https://github.com/${{ github.repository }}/actions">ActionsList</a>
126126
127-
Commit with tag: ${{ needs.prepare.outputs.CURRENT_TAG }}
127+
Commit with tag: ${{ env.CURRENT_TAG }}
128128
129129
Repository: ${{ github.repository }}
130130

.github/workflows/code_quality.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,32 @@ jobs:
3535
<b>!!! FAILED !!!</b>
3636
<b>Failed job:</b> https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
3737
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
38+
39+
pytesting:
40+
runs-on: ubuntu-latest
41+
name: Testing with pytest
42+
container: python:3.9
43+
needs: [ code_quality ]
44+
45+
steps:
46+
47+
- name: Checkout code
48+
uses: actions/checkout@v2
49+
50+
- name: Run script
51+
run: pip install -r requirements.txt
52+
53+
- name: Testing
54+
run: pytest -v ./tests/
55+
56+
- name: Notify if failure
57+
if: ${{ failure() }}
58+
uses: appleboy/telegram-action@master
59+
with:
60+
to: ${{ secrets.TELEGRAM_CHAT }}
61+
token: ${{ secrets.TELEGRAM_TOKEN }}
62+
format: html
63+
message: |
64+
<b>!!! FAILED !!!</b>
65+
<b>Failed job:</b> https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
66+
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ jobs:
103103
include:
104104
- os: windows-latest
105105
TARGET: windows
106-
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F truth_seeker.py
106+
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F ./app/truth_seeker.py
107107
OUT_FILE_NAME: truth_seeker.exe
108108
ASSET_MIME: application/vnd.microsoft.portable-executable
109109
- os: ubuntu-latest
110110
TARGET: ubuntu
111-
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F truth_seeker.py
111+
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F ./app/truth_seeker.py
112112
OUT_FILE_NAME: truth_seeker
113113
ASSET_MIME: application/x-binary
114114

@@ -143,7 +143,7 @@ jobs:
143143
env:
144144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145145
with:
146-
upload_url: ${{ needs.release.outputs.RELEASE_URL }}
146+
upload_url: ${{ env.RELEASE_URL }}
147147
asset_path: ./dist/${{ matrix.OUT_FILE_NAME }}
148148
asset_name: ${{ matrix.OUT_FILE_NAME }}
149149
asset_content_type: ${{ matrix.ASSET_MIME }}
File renamed without changes.

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
black
22
isort
33
pyinstaller
4+
pytest~=7.1.3
5+
dynaconfig~=0.4
46
dynaconf~=3.1.11
5-
newsapi-python~=0.2.6
7+
newsapi-python~=0.2.6

tests/__init__.py

Whitespace-only changes.

tests/test_truth_seeker.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from app import truth_seeker
2+
3+
4+
def test_fetch_info():
5+
"""
6+
Simple test for fetching func
7+
:return:
8+
"""
9+
return isinstance(truth_seeker.fetch_info("test"), dict)
10+
11+
12+
def test_fetch_info_empty():
13+
"""
14+
Empty query
15+
:return:
16+
"""
17+
return isinstance(truth_seeker.fetch_info(""), dict)

0 commit comments

Comments
 (0)