From 7702018e8bbc52faa54f4e782e775fd2f694a367 Mon Sep 17 00:00:00 2001 From: Lucino772 Date: Tue, 23 Mar 2021 23:31:09 +0100 Subject: [PATCH] Unittesting on basic features --- tests/__init__.py | 0 tests/test_mojang.py | 34 ++++++++++++++++++++++++++++++++++ tests/test_user.py | 16 ++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_mojang.py create mode 100644 tests/test_user.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_mojang.py b/tests/test_mojang.py new file mode 100644 index 00000000..575ba8be --- /dev/null +++ b/tests/test_mojang.py @@ -0,0 +1,34 @@ +import unittest +import mojang + +class TestMojangAPI(unittest.TestCase): + + def test_existent_uuid(self): + self.assertEqual(mojang.get_uuid('Notch'), '069a79f444e94726a5befca90e38aaf5') + self.assertEqual(mojang.get_uuid('jeb_'), '853c80ef3c3749fdaa49938b674adae6') + + def test_unexistent_uuid(self): + self.assertEqual(mojang.get_uuid('UNEXISTENT_PLAYER'), None) + + def test_existent_uuids(self): + self.assertEqual(mojang.get_uuids(['Notch','jeb_']), ['069a79f444e94726a5befca90e38aaf5','853c80ef3c3749fdaa49938b674adae6']) + self.assertEqual(mojang.get_uuids(['jeb_','Notch']), ['853c80ef3c3749fdaa49938b674adae6','069a79f444e94726a5befca90e38aaf5']) + + def test_unexistent_uuids(self): + self.assertEqual(mojang.get_uuids(['jeb_','UNEXISTENT_PLAYER']), ['853c80ef3c3749fdaa49938b674adae6',None]) + self.assertEqual(mojang.get_uuids(['UNEXISTENT_PLAYER1','UNEXISTENT_PLAYER2']), [None,None]) + + def test_existent_name(self): + self.assertEqual(mojang.get_username('069a79f444e94726a5befca90e38aaf5'), 'Notch') + self.assertEqual(mojang.get_username('853c80ef3c3749fdaa49938b674adae6'), 'jeb_') + + def test_unexistent_name(self): + self.assertEqual(mojang.get_username('069a79f444e94726a5befca90e38aaf6'), None) + + def test_existent_names(self): + self.assertEqual(mojang.name_history('069a79f444e94726a5befca90e38aaf5'), [('Notch',None)]) + self.assertEqual(mojang.name_history('853c80ef3c3749fdaa49938b674adae6'), [('jeb_', None)]) + + def test_unexistent_names(self): + self.assertEqual(mojang.name_history('069a79f444e94726a5befca90e38aaf6'), []) + \ No newline at end of file diff --git a/tests/test_user.py b/tests/test_user.py new file mode 100644 index 00000000..8940175d --- /dev/null +++ b/tests/test_user.py @@ -0,0 +1,16 @@ +import unittest +import mojang + + +class TestMojangUser(unittest.TestCase): + + def test_existent_profile(self): + profile = mojang.user('Notch') + self.assertEqual(profile.name, 'Notch') + self.assertEqual(profile.uuid, '069a79f444e94726a5befca90e38aaf5') + self.assertEqual(profile.is_legacy, False) + self.assertEqual(profile.is_demo, False) + self.assertEqual(profile.names, [('Notch', None)]) + + def test_unexistent_profile(self): + self.assertEqual(mojang.user('UNEXISTENT_PLAYER'), None)