Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion kanboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def __init__(
self._timeout = timeout
self._ignore_hostname_verification = ignore_hostname_verification

if not loop:
if loop:
self._event_loop = loop
else:
try:
self._event_loop = asyncio.get_event_loop()
except RuntimeError:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_kanboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import asyncio
import types
import unittest
import warnings
Expand Down Expand Up @@ -112,6 +113,14 @@ def test_async_call_returns_result(self):
result = loop.run_until_complete(self.client.my_method_async())
self.assertEqual(42, result)

def test_custom_event_loop(self):
custom_loop = asyncio.new_event_loop()
try:
client = kanboard.Client(self.url, "username", "password", loop=custom_loop)
self.assertIs(client._event_loop, custom_loop)
finally:
custom_loop.close()

def test_custom_user_agent(self):
client = kanboard.Client(self.url, "username", "password", user_agent="CustomAgent/1.0")
body = b'{"jsonrpc": "2.0", "result": true, "id": 123}'
Expand Down