Skip to content

Commit

Permalink
test: implement test for is_button_affiliated method
Browse files Browse the repository at this point in the history
  • Loading branch information
d-Rickyy-b committed Sep 13, 2020
1 parent 31f5241 commit 5dfa186
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions blackjackbot/commands/game/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
37 changes: 37 additions & 0 deletions blackjackbot/commands/game/tests/functions_test.py
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()
1 change: 1 addition & 0 deletions blackjackbot/util/tests/textutils_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import unittest
from unittest.mock import Mock

Expand Down

0 comments on commit 5dfa186

Please sign in to comment.