From 4d3c75063a8370294cd3b9b6ee662bffdc31f242 Mon Sep 17 00:00:00 2001
From: Pavel Kirilin <win10@list.ru>
Date: Mon, 29 Jun 2020 03:14:55 +0400
Subject: [PATCH] Fixed tests.

Signed-off-by: Pavel Kirilin <win10@list.ru>
---
 tests/conftest.py | 12 ++++++++++++
 tests/test_fun.py |  4 ++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/tests/conftest.py b/tests/conftest.py
index 829732d..9b5fda3 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,5 +1,7 @@
 from unittest.mock import MagicMock
 
+import pytest
+
 
 class NewMessageTestEvent(object):
     def __init__(self, message: str, forwarded=False):
@@ -28,3 +30,13 @@ class NewMessageTestEvent(object):
         message = MagicMock()
         message.message = self._msg
         return message
+
+    async def get_chat(self):
+        return MagicMock()
+
+
+@pytest.fixture
+def patch_mark_dialogue_unread():
+    import telethon
+
+    telethon.functions.messages.MarkDialogUnreadRequest = MagicMock(returning=True)
diff --git a/tests/test_fun.py b/tests/test_fun.py
index 1d3acd2..f97eba3 100644
--- a/tests/test_fun.py
+++ b/tests/test_fun.py
@@ -5,14 +5,14 @@ from tests.conftest import NewMessageTestEvent
 
 
 @pytest.mark.asyncio
-async def test_bl_trailing_comma():
+async def test_bl_trailing_comma(patch_mark_dialogue_unread):
     event_mock = NewMessageTestEvent("test,")
     await fun.blyaficate(event_mock)
     assert not event_mock.result.endswith(",")
 
 
 @pytest.mark.asyncio
-async def test_bl_starting_comma():
+async def test_bl_starting_comma(patch_mark_dialogue_unread):
     event_mock = NewMessageTestEvent(",test.")
     await fun.blyaficate(event_mock)
     assert not event_mock.result.startswith(",")
-- 
GitLab