Skip to content

Commit

Permalink
Test Coverage and Code Tidy (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc authored Dec 17, 2023
1 parent a175f16 commit cda6925
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.py310
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FROM python:3.10-buster
RUN apt-get update && \
apt-get install -y --no-install-recommends libdbus-1-dev libgirepository1.0-dev build-essential musl-dev bash dbus && \
rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir dbus-python PyGObject
RUN pip install --no-cache-dir dbus-python "PyGObject==3.44.2"

# Apprise Setup
VOLUME ["/apprise"]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.py311
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FROM python:3.11-buster
RUN apt-get update && \
apt-get install -y --no-install-recommends libdbus-1-dev libgirepository1.0-dev build-essential musl-dev bash dbus && \
rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir dbus-python PyGObject
RUN pip install --no-cache-dir dbus-python "PyGObject==3.44.2"

# Apprise Setup
VOLUME ["/apprise"]
Expand Down
2 changes: 1 addition & 1 deletion apprise/plugins/NotifyAprs.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def send(self, body, title="", notify_type=NotifyType.INFO, **kwargs):
# see https://www.aprs.org/doc/APRS101.PDF pg. 71
payload = re.sub("[{}|~]+", "", payload)

payload = (
payload = ( # pragma: no branch
APRS_COMPILED_MAP.sub(
lambda x: APRS_BAD_CHARMAP[x.group()], payload)
)
Expand Down
2 changes: 1 addition & 1 deletion apprise/plugins/NotifyBulkSMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def send(self, body, title='', notify_type=NotifyType.INFO, **kwargs):

if not (self.targets or self.groups):
# We have nothing to notify
self.logger.warning('There are no Twist targets to notify')
self.logger.warning('There are no BulkSMS targets to notify')
return False

# Send in batches if identified to do so
Expand Down
63 changes: 37 additions & 26 deletions apprise/plugins/NotifyMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,28 +727,38 @@ def _send_attachments(self, attach):
# "content_uri": "mxc://example.com/a-unique-key"
# }

if self.version == MatrixVersion.V3:
# Prepare our payload
payloads.append({
"body": attachment.name,
"info": {
"mimetype": attachment.mimetype,
"size": len(attachment),
},
"msgtype": "m.image",
"url": response.get('content_uri'),
})

else:
# Prepare our payload
payloads.append({
"info": {
"mimetype": attachment.mimetype,
},
"msgtype": "m.image",
"body": "tta.webp",
"url": response.get('content_uri'),
})
# FUTURE if self.version == MatrixVersion.V3:
# FUTURE # Prepare our payload
# FUTURE payloads.append({
# FUTURE "body": attachment.name,
# FUTURE "info": {
# FUTURE "mimetype": attachment.mimetype,
# FUTURE "size": len(attachment),
# FUTURE },
# FUTURE "msgtype": "m.image",
# FUTURE "url": response.get('content_uri'),
# FUTURE })

# FUTURE else:
# FUTURE # Prepare our payload
# FUTURE payloads.append({
# FUTURE "info": {
# FUTURE "mimetype": attachment.mimetype,
# FUTURE },
# FUTURE "msgtype": "m.image",
# FUTURE "body": "tta.webp",
# FUTURE "url": response.get('content_uri'),
# FUTURE })

# Prepare our payload
payloads.append({
"info": {
"mimetype": attachment.mimetype,
},
"msgtype": "m.image",
"body": "tta.webp",
"url": response.get('content_uri'),
})

return payloads

Expand Down Expand Up @@ -1131,11 +1141,12 @@ def _fetch(self, path, payload=None, params=None, attachment=None,
or self.port == default_port else f':{self.port}')

if path == '/upload':
if self.version == MatrixVersion.V3:
url += MATRIX_V3_MEDIA_PATH + path
# FUTURE if self.version == MatrixVersion.V3:
# FUTURE url += MATRIX_V3_MEDIA_PATH + path

else:
url += MATRIX_V2_MEDIA_PATH + path
# FUTURE else:
# FUTURE url += MATRIX_V2_MEDIA_PATH + path
url += MATRIX_V2_MEDIA_PATH + path

params = {'filename': attachment.name}
with open(attachment.path, 'rb') as fp:
Expand Down
2 changes: 1 addition & 1 deletion test/test_plugin_bulksms.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_plugin_bulksms_edge_cases(mock_post):
# Prepare Mock
mock_post.return_value = response

# Test our markdown
# Instantiate our object
obj = Apprise.instantiate(
'bulksms://{}:{}@{}?batch=n'.format(user, pwd, '/'.join(targets)))

Expand Down

0 comments on commit cda6925

Please sign in to comment.