-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from kilobyteno/code-style
- Loading branch information
Showing
13 changed files
with
144 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ENV=staging | ||
|
||
TEST_API_TOKEN= | ||
TEST_PROJECT_ID= | ||
TEST_CHANNEL_ID= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[flake8] | ||
max-line-length = 160 | ||
ignore = D104, D400, D210, D101, D100, D107, D106, I100, I202, I101 | ||
import-order-style = pycharm | ||
statistics = True | ||
exclude = | ||
.git, | ||
__pycache__, | ||
.github, | ||
.pytest_cache, | ||
venv, | ||
build, | ||
dist, | ||
oppe.egg-info, | ||
.eggs, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: "Code Style" | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- synchronize | ||
- opened | ||
- edited | ||
|
||
jobs: | ||
validation: | ||
name: "Validation" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [ "3.8", "3.9", "3.10" ] | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ inputs.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' # caching pip dependencies | ||
- name: Install All Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r all.txt | ||
- name: Run flake8 | ||
run: | | ||
flake8 --config=.flake8 | ||
- name: Check for vulnerabilities | ||
uses: pypa/gh-action-pip-audit@v1.0.6 | ||
with: | ||
inputs: requirements.txt requirements-dev.txt | ||
- name: Rename file | ||
run: mv .env.example .env | ||
- name: Change environment variables in .env | ||
run: | | ||
sed -i "s/TEST_API_TOKEN=/TEST_API_TOKEN=${{ secrets.TEST_API_TOKEN }}/g" .env | ||
sed -i "s/TEST_PROJECT_ID=/TEST_PROJECT_ID=${{ secrets.TEST_PROJECT_ID }}/g" .env | ||
sed -i "s/TEST_CHANNEL_ID=/TEST_CHANNEL_ID=${{ secrets.TEST_CHANNEL_ID }}/g" .env | ||
- name: Run Tests | ||
run: | | ||
pytest --disable-pytest-warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
repos: | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 6.0.0 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: [flake8-print, flake8-quotes, flake8-use-fstring, pep8-naming, flake8-import-order, flake8-docstrings] | ||
args: [--config=.flake8] | ||
exclude: ^(.git|__pycache__|.github|.pytest_cache|venv|build|dist|oppe.egg-info|.eggs)/.*\.py$ | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
name: isort (python) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-r requirements-dev.txt | ||
-r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Init file for oppe""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
flake8~=6.1.0 | ||
flake8-docstrings~=1.7.0 | ||
flake8-import-order~=0.18.2 | ||
flake8-print~=5.0.0 | ||
flake8-quotes~=3.3.2 | ||
flake8-use-fstring~=1.4.0 | ||
isort~=5.12.0 | ||
pre-commit~=3.4.0 | ||
Faker~=19.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
from faker import Faker | ||
|
||
from oppe.oppe import Oppe | ||
|
||
fake = Faker() | ||
|
||
# Reading the env variables | ||
dotenv_path = os.path.join(os.path.dirname(__file__), '..', '.env') | ||
if os.path.exists(dotenv_path): | ||
load_dotenv(dotenv_path) | ||
|
||
|
||
def init_oppe(): | ||
return Oppe(token=os.getenv('TEST_API_TOKEN'), project=os.getenv('TEST_PROJECT')) | ||
""" Initialize Oppe """ | ||
return Oppe(token=os.getenv('TEST_API_TOKEN'), project=os.getenv('TEST_PROJECT_ID')) | ||
|
||
|
||
def test_publish_event(): | ||
""" Test publish event """ | ||
oppe = init_oppe() | ||
response = oppe.trigger_event(channel=os.getenv('TEST_CHANNEL_ID'), title=os.getenv('TEST_TITLE'), description=os.getenv('TEST_DESCRIPTION')) | ||
assert response == True | ||
response = oppe.trigger_event(channel=os.getenv('TEST_CHANNEL_ID'), title=fake.domain_word(), description=fake.sentence()) | ||
assert response is True |