Skip to content

Commit

Permalink
Unittesting on basic features
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucino772 authored and lpalmisa committed Mar 23, 2021
1 parent 6a3a5b2 commit 7702018
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
Empty file added tests/__init__.py
Empty file.
34 changes: 34 additions & 0 deletions tests/test_mojang.py
Original file line number Diff line number Diff line change
@@ -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'), [])

16 changes: 16 additions & 0 deletions tests/test_user.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 7702018

Please sign in to comment.