-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace uses of old .count() method in queries
- Loading branch information
Aspen Barnes
committed
Aug 24, 2021
1 parent
7a55dc9
commit c03f18a
Showing
4 changed files
with
88 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ omit = | |
tests/data/* | ||
tests/util/* | ||
.* | ||
venv/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import time | ||
from unittest.mock import MagicMock, call | ||
|
||
from plugins import quote | ||
|
||
|
||
def test_add_quote(mock_db, freeze_time): | ||
db = mock_db.session() | ||
quote.qtable.create(bind=mock_db.engine) | ||
chan = "#foo" | ||
target = "bar" | ||
sender = "baz" | ||
msg = "Some test quote" | ||
quote.add_quote(db, chan, target, sender, msg) | ||
assert mock_db.get_data(quote.qtable) == [ | ||
(chan, target, sender, msg, time.time(), False) | ||
] | ||
|
||
|
||
def test_quote_cmd_add(mock_db, freeze_time): | ||
db = mock_db.session() | ||
quote.qtable.create(bind=mock_db.engine) | ||
chan = "#foo" | ||
target = "bar" | ||
sender = "baz" | ||
msg = "Some test quote" | ||
text = "add " + target + " " + msg | ||
event = MagicMock() | ||
res = quote.quote(text, sender, chan, db, event) | ||
assert res is None | ||
assert mock_db.get_data(quote.qtable) == [ | ||
(chan, target, sender, msg, time.time(), False) | ||
] | ||
assert event.mock_calls == [call.notice("Quote added.")] | ||
|
||
|
||
def test_quote_cmd_get_nick_random(mock_db, freeze_time): | ||
db = mock_db.session() | ||
quote.qtable.create(bind=mock_db.engine) | ||
chan = "#foo" | ||
target = "bar" | ||
sender = "baz" | ||
msg = "Some test quote" | ||
quote.add_quote(db, chan, target, sender, msg) | ||
text = target | ||
event = MagicMock() | ||
res = quote.quote(text, sender, chan, db, event) | ||
assert res == "[1/1] <b\u200bar> Some test quote" | ||
# assert mock_db.get_data(quote.qtable) == [(chan, target, sender, msg, time.time(), False)] | ||
assert event.mock_calls == [] | ||
|
||
|
||
def test_quote_cmd_get_chan_random(mock_db, freeze_time): | ||
db = mock_db.session() | ||
quote.qtable.create(bind=mock_db.engine) | ||
chan = "#foo" | ||
target = "bar" | ||
sender = "baz" | ||
msg = "Some test quote" | ||
quote.add_quote(db, chan, target, sender, msg) | ||
text = chan | ||
event = MagicMock() | ||
res = quote.quote(text, sender, chan, db, event) | ||
assert res == "[1/1] <b\u200bar> Some test quote" | ||
assert event.mock_calls == [] | ||
|
||
|
||
def test_quote_cmd_get_nick_chan_random(mock_db, freeze_time): | ||
db = mock_db.session() | ||
quote.qtable.create(bind=mock_db.engine) | ||
chan = "#foo" | ||
target = "bar" | ||
sender = "baz" | ||
msg = "Some test quote" | ||
quote.add_quote(db, chan, target, sender, msg) | ||
text = chan + " " + target | ||
event = MagicMock() | ||
res = quote.quote(text, sender, chan, db, event) | ||
assert res == "[1/1] <b\u200bar> Some test quote" | ||
assert event.mock_calls == [] |