X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Ftests%2Ftest_actions.py;h=5cf4c76011958267a324087a7a5eae9706fe6b19;hb=87f51eafe4495e6ca13cf1702e0c9dce4862dc49;hp=3497ee49c6a47d7971e5e67f3b1ca03ebbf1be42;hpb=5e1dcec78f42c4b6a1252bb2fdf6eafb1c32dd59;p=naja.git diff --git a/naja/tests/test_actions.py b/naja/tests/test_actions.py index 3497ee4..5cf4c76 100644 --- a/naja/tests/test_actions.py +++ b/naja/tests/test_actions.py @@ -50,6 +50,33 @@ class TestActions(TestCase): check_available(set([BITS.MSB]), [], False) check_available(set([BITS.MSB]), [BITS.MSB], True) + def test_get_text(self): + class LocationAction1(actions.LocationAction): + TEXT = "foo" + action1 = LocationAction1([]) + self.assertEqual(action1.get_text(), "foo") + + class LocationAction2(actions.LocationAction): + TEXT = "foo %(bar)s" + action2 = LocationAction2([], bar="baz") + self.assertEqual(action2.get_text(), "foo baz") + + def test_get_text_row_column(self): + class DirectionAction(actions.LocationAction): + TEXT = "foo %(direction)s %(rowcol)s" + + action_north = DirectionAction([], direction='NORTH') + self.assertEqual(action_north.get_text(), "foo NORTH column") + + action_south = DirectionAction([], direction='SOUTH') + self.assertEqual(action_south.get_text(), "foo SOUTH column") + + action_east = DirectionAction([], direction='EAST') + self.assertEqual(action_east.get_text(), "foo EAST row") + + action_west = DirectionAction([], direction='WEST') + self.assertEqual(action_west.get_text(), "foo WEST row") + def test_bits_translation(self): action = actions.LocationAction(set([BITS.NORTH, 'MSB'])) self.assertEqual(action.required_bits, set([BITS.NORTH, BITS.MSB]))