Created
September 7, 2019 14:56
-
-
Save Ah-da-Coder/a75426f752126ed1c6ef924914ebe8fa to your computer and use it in GitHub Desktop.
Stateパターンのテストコード
This file contains hidden or 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
| import unittest | |
| from src.state import Context | |
| class StateTest(unittest.TestCase): | |
| def setUp(self): | |
| self.context = Context() | |
| def test_initial_state(self): | |
| state = self.context.state | |
| self.assertEqual(state.action_name, "起きる") | |
| self.assertEqual(state.greeting_word, "おはよう") | |
| def test_change_state(self): | |
| state = self.context.state | |
| self.assertEqual(state.action_name, "起きる") | |
| self.context.change_state("一日の終わり") | |
| state = self.context.state | |
| self.assertEqual(state.action_name, "寝る") | |
| def test_not_registered_state_raise_exception(self): | |
| with self.assertRaises(ValueError): | |
| self.context.change_state("登録されていないステート") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment