Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #321

Merged
merged 18 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ name: Python application

on:
push:
branches: [ master ]
branches:
- '**'
create:
branches:
- '**'
tags:
- '**'
pull_request:
branches: [ master ]
branches:
- master # Run on pull requests targeting the master branch

jobs:
build:
Expand All @@ -31,6 +38,16 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Check formatting
run: |
# stop the build if there are formatting is error in any python codes
# to check whether the codes are formatted or not before merge
pip install black==24.4.2
pip install click==8.1.7
python -m black -t py310 --check .
- name: Test with pytest
run: |
pytest
export FCM_TEST_API_KEY=AAA
export FCM_TEST_PROJECT_ID=test
pip install . ".[test]"
python -m pytest .
12 changes: 9 additions & 3 deletions pyfcm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
__version__,
__author__,
__email__,
__license__
__license__,
)
from .fcm import FCMNotification

__all__ = [
"FCMNotification", "__title__", "__summary__",
"__url__", "__version__", "__author__", "__email__", "__license__"
"FCMNotification",
"__title__",
"__summary__",
"__url__",
"__version__",
"__author__",
"__email__",
"__license__",
]
14 changes: 7 additions & 7 deletions pyfcm/__meta__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
__title__ = 'pyfcm'
__summary__ = 'Python client for FCM - Firebase Cloud Messaging (Android, iOS and Web)'
__url__ = 'https://github.com/olucurious/pyfcm'
__title__ = "pyfcm"
__summary__ = "Python client for FCM - Firebase Cloud Messaging (Android, iOS and Web)"
__url__ = "https://github.com/olucurious/pyfcm"

__version__ = '1.5.2'
__version__ = "1.5.2"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
__version__ = "1.5.2"
__version__ = "1.5.5"

need to fix version string 1.5.5 or somthing

__author__ = 'Emmanuel Adegbite'
__email__ = '[email protected]'
__author__ = "Emmanuel Adegbite"
__email__ = "[email protected]"

__license__ = 'MIT License'
__license__ = "MIT License"
18 changes: 13 additions & 5 deletions pyfcm/async_fcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import aiohttp
import json

async def fetch_tasks(end_point,headers,payloads,timeout):

async def fetch_tasks(end_point, headers, payloads, timeout):
"""

:param end_point (str) : FCM endpoint
Expand All @@ -11,11 +12,18 @@ async def fetch_tasks(end_point,headers,payloads,timeout):
:param timeout (int) : FCM timeout
:return:
"""
fetches = [asyncio.Task(send_request(end_point=end_point,headers=headers,payload=payload,timeout=timeout)) for payload in payloads]
fetches = [
asyncio.Task(
send_request(
end_point=end_point, headers=headers, payload=payload, timeout=timeout
)
)
for payload in payloads
]
return await asyncio.gather(*fetches)


async def send_request(end_point,headers,payload,timeout=5):
async def send_request(end_point, headers, payload, timeout=5):
"""

:param end_point (str) : FCM endpoint
Expand All @@ -26,9 +34,9 @@ async def send_request(end_point,headers,payload,timeout=5):
"""
timeout = aiohttp.ClientTimeout(total=timeout)

async with aiohttp.ClientSession(headers=headers,timeout=timeout) as session:
async with aiohttp.ClientSession(headers=headers, timeout=timeout) as session:

async with session.post(end_point,data=payload) as res:
async with session.post(end_point, data=payload) as res:
result = await res.text()
result = json.loads(result)
return result
Loading
Loading