-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: implement test for is_button_affiliated method
- Loading branch information
1 parent
31f5241
commit 5dfa186
Showing
3 changed files
with
39 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
# -*- coding: utf-8 -*- |
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,37 @@ | ||
# -*- coding: utf-8 -*- | ||
import unittest | ||
from unittest.mock import Mock | ||
|
||
from blackjackbot.commands.game.functions import is_button_affiliated | ||
|
||
|
||
class GameCommandsFunctionsTest(unittest.TestCase): | ||
|
||
def test_is_button_affiliated_positive(self): | ||
"""Check if button assignment is calculated correctly - game.id and data.id are equal""" | ||
game = Mock() | ||
game.id = 133769420 | ||
update = Mock() | ||
update.callback_query = Mock() | ||
update.callback_query.answer = Mock() | ||
update.callback_query.data = "start_{}".format(game.id) | ||
|
||
result = is_button_affiliated(update, Mock(), game, "en") | ||
self.assertTrue(result) | ||
|
||
def test_is_button_affiliated_negative(self): | ||
"""Check if button assignment is calculated correctly - game.id and data.id differ""" | ||
game = Mock() | ||
game.id = 420133769 | ||
update = Mock() | ||
update.callback_query = Mock() | ||
update.callback_query.answer = Mock() | ||
update.callback_query.data = "start_133769420" | ||
|
||
result = is_button_affiliated(update, Mock(), game, "en") | ||
self.assertFalse(result) | ||
update.callback_query.answer.assert_called_once() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
import unittest | ||
from unittest.mock import Mock | ||
|
||
|