Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
indicators-parser-saas
backend
Commits
25dea777
Verified
Commit
25dea777
authored
2 years ago
by
Власов Иван Юрьевич
Browse files
Options
Download
Patches
Plain Diff
Added tests for telegram watchers
parent
79560d0e
master
No related merge requests found
Pipeline
#98833
failed with stage
in 1 minute and 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/fixtures/telegram.py
+7
-0
tests/fixtures/telegram.py
tests/test_watcher.py
+34
-0
tests/test_watcher.py
with
41 additions
and
0 deletions
+41
-0
tests/fixtures/telegram.py
0 → 100644
+
7
−
0
View file @
25dea777
import
pytest
from
integrations.telegram
import
client
@pytest.fixture
()
def
telegram
():
client
.
start
()
This diff is collapsed.
Click to expand it.
tests/test_watcher.py
0 → 100644
+
34
−
0
View file @
25dea777
from
os
import
getenv
from
models
import
IndicatorGroup
,
Indicator
from
models.watcher
import
TelegramWatcher
from
tests.fixtures.telegram
import
telegram
from
tests.fixtures.tortoise
import
user
from
integrations.telegram
import
on_message
from
telethon.tl.custom
import
Message
import
pytest
@pytest.mark.skipif
(
getenv
(
"SKIP_TELEGRAM_TESTS"
),
reason
=
"Telegram tests are skipped"
)
@pytest.mark.asyncio
async
def
test_watcher
(
telegram
,
user
):
await
TelegramWatcher
.
from_telegram_link
(
"https://t.me/+xkMQwHvx2wsyMDEy"
,
user
)
indicator_groups
=
await
IndicatorGroup
.
filter
(
owner
=
user
).
count
()
assert
indicator_groups
==
1
@pytest.mark.skip
()
@pytest.mark.asyncio
async
def
test_watcher_message
(
telegram
,
user
):
watcher
=
await
TelegramWatcher
.
from_telegram_link
(
"https://t.me/+xkMQwHvx2wsyMDEy"
,
user
)
message
=
Message
(
message
=
"Hash: 098890dde069e9abad63f19a0d9e1f32, Url: https://google.com"
,
id
=
4
,
peer_id
=
1749453629
)
await
on_message
(
message
)
assert
(
await
Indicator
.
filter
(
indicator_group_id
=
watcher
.
indicator_group_id
).
count
())
==
2
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets