X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Ftests%2Ftest_player.py;h=c748c7295827b9e1355c6cb3f0e6182f049585b2;hb=b3db4400695249420f5f941744c2a2692a1bad98;hp=d2b896e402b3983c6b594d5e3c12c24f0304b482;hpb=ede149141d8dcbd6bed5bf3ff710d2f716ac8421;p=naja.git diff --git a/naja/tests/test_player.py b/naja/tests/test_player.py index d2b896e..c748c72 100644 --- a/naja/tests/test_player.py +++ b/naja/tests/test_player.py @@ -1,7 +1,7 @@ from unittest import TestCase from naja.constants import BITS -from naja.player import PlayerBits +from naja.player import PlayerBits, Player class TestPlayerBits(TestCase): @@ -84,3 +84,25 @@ class TestPlayerBits(TestCase): self.assertEqual(bits._bits, 0x03) bits.toggle_bits([BITS.NORTH, BITS.CYAN, BITS.MSB]) self.assertEqual(bits._bits, 0x92) + + +class TestPlayer(TestCase): + def test_new_player(self): + player = Player(0x0f, (0, 1)) + self.assertEqual(player.bits.bits, 0x0f) + self.assertEqual(player.position, (0, 1)) + + def test_import_player(self): + player = Player.import_player({ + 'bits': 0xaa, + 'position': [1, 2], + }) + self.assertEqual(player.bits.bits, 0xaa) + self.assertEqual(player.position, (1, 2)) + + def test_export_player(self): + player = Player(0xaa, (1, 2)) + self.assertEqual(player.export(), { + 'bits': 0xaa, + 'position': [1, 2], + })