Skip to content

Commit

Permalink
Improved coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
tonioo committed Mar 27, 2024
1 parent 5a571bf commit 3e3e06f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 36 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/sievelib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,31 @@ jobs:
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml

release:
if: github.event_name != 'pull_request'
needs: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Publish to Test PyPI
if: endsWith(github.event.ref, '/master')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish distribution to PyPI
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
skip_existing: true
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

7 changes: 3 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sievelib
========

|travis| |codecov| |latest-version|
|workflow| |codecov| |latest-version|

Client-side Sieve and Managesieve library written in Python.

Expand Down Expand Up @@ -130,7 +130,7 @@ supported, with a simulated behaviour for server that do not support
it.

For the ``AUTHENTICATE`` command, supported mechanisms are ``DIGEST-MD5``,
``PLAIN`` and ``LOGIN``.
``PLAIN``, ``LOGIN`` and ``OAUTHBEARER``.

Basic usage
^^^^^^^^^^^
Expand All @@ -154,7 +154,6 @@ Additional documentation is available with source code.

.. |latest-version| image:: https://badge.fury.io/py/sievelib.svg
:target: https://badge.fury.io/py/sievelib
.. |travis| image:: https://travis-ci.org/tonioo/sievelib.png?branch=master
:target: https://travis-ci.org/tonioo/sievelib
.. |workflow| image:: https://github.com/tonioo/sievelib/workflows/Sievelib/badge.svg
.. |codecov| image:: http://codecov.io/github/tonioo/sievelib/coverage.svg?branch=master
:target: http://codecov.io/github/tonioo/sievelib?branch=master
2 changes: 1 addition & 1 deletion sievelib/managesieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def capability(self):
return None

@authentication_required
def havespace(self, scriptname, scriptsize):
def havespace(self, scriptname: str, scriptsize: int) -> bool:
"""Ask for available space.
See MANAGESIEVE specifications, section 2.5
Expand Down
11 changes: 9 additions & 2 deletions sievelib/tests/test_managesieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
CAPABILITIES = (
b'"IMPLEMENTATION" "Example1 ManageSieved v001"\r\n'
b'"VERSION" "1.0"\r\n'
b'"SASL" "PLAIN SCRAM-SHA-1 GSSAPI"\r\n'
b'"SASL" "PLAIN SCRAM-SHA-1 GSSAPI OAUTHBEARER"\r\n'
b'"SIEVE" "fileinto vacation"\r\n'
b'"STARTTLS"\r\n'
)

CAPABILITIES_WITHOUT_VERSION = (
b'"IMPLEMENTATION" "Example1 ManageSieved v001"\r\n'
b'"SASL" "PLAIN SCRAM-SHA-1 GSSAPI"\r\n'
b'"SASL" "PLAIN SCRAM-SHA-1 GSSAPI OAUTHBEARER"\r\n'
b'"SIEVE" "fileinto vacation"\r\n'
b'"STARTTLS"\r\n'
)
Expand Down Expand Up @@ -64,6 +64,13 @@ def test_connection(self, mock_socket):
mock_socket.return_value.recv.side_effect = (b"OK test\r\n", )
self.client.logout()

def test_auth_oauthbearer(self, mock_socket):
"""Test OAUTHBEARER mechanism."""
mock_socket.return_value.recv.side_effect = (AUTHENTICATION, )
self.assertTrue(
self.client.connect(b"user", b"token", authmech="OAUTHBEARER")
)

def test_capabilities(self, mock_socket):
"""Test capabilities command."""
self.authenticate(mock_socket)
Expand Down

0 comments on commit 3e3e06f

Please sign in to comment.