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

Allow target count returns from len(Service) calls #874

Merged
merged 4 commits into from
May 13, 2023
Merged

Conversation

caronc
Copy link
Owner

@caronc caronc commented May 12, 2023

Description:

Related issue (if applicable): n/a

This is just a change to the underlining API. A call to len(BaseService) will now return the number of targets configured to be notified.

Some plugins support a batch mode ?batch=yes. In these cases, the fact that a lot of targets can all be lumped into a single API call by apprise is factored into the len() call. The return will be set to the number of API calls needed to deliver the payload instead of the target counts in this case.

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@target-counts

# launch a python instance
python

# The following commands assume you're now in a python interpreter:
import apprise

aobj = apprise.Apprise()

aobj.add('mailto://user:pass@localhost/abc@yahoo.ca/def@yahoo.ca')

# len() on the service object inside now returns the number of targets
# We added 2 emails to the above plugin, so the first internal object added
# to our apprise object (a NotifyMail() class) will return 2 when len()
# is called on it.
assert len(aobj[0]) == 2

@codecov-commenter
Copy link

codecov-commenter commented May 13, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (00ddb09) 100.00% compared to head (52ea3cf) 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##            master      #874    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          118       118            
  Lines        15377     15572   +195     
  Branches      3154      3173    +19     
==========================================
+ Hits         15377     15572   +195     
Impacted Files Coverage Δ
apprise/URLBase.py 100.00% <100.00%> (ø)
apprise/plugins/NotifyBark.py 100.00% <100.00%> (ø)
apprise/plugins/NotifyBoxcar.py 100.00% <100.00%> (ø)
apprise/plugins/NotifyBulkSMS.py 100.00% <100.00%> (ø)
apprise/plugins/NotifyClickSend.py 100.00% <100.00%> (ø)
apprise/plugins/NotifyD7Networks.py 100.00% <100.00%> (ø)
apprise/plugins/NotifyDapnet.py 100.00% <100.00%> (ø)
apprise/plugins/NotifyDingTalk.py 100.00% <100.00%> (ø)
apprise/plugins/NotifyEmail.py 100.00% <100.00%> (ø)
apprise/plugins/NotifyFCM/__init__.py 100.00% <100.00%> (ø)
... and 42 more

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@caronc caronc merged commit c542ab2 into master May 13, 2023
16 checks passed
@caronc caronc deleted the target-counts branch May 13, 2023 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants