Skip to content

Commit

Permalink
Renaming functions status, names & user (#22)
Browse files Browse the repository at this point in the history
* refactor: renamed status to get_status, names to get_names & user to get_profile

* fix(tests): updated imports in tests functions

* chore: updated README.md
  • Loading branch information
Lucino772 authored Jan 31, 2022
1 parent ba141f5 commit 45b0795
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ New features:
- [ ] `get_username` : This function return the username for a given uuid

The following functions are going to be renamed:
- [ ] `status` → `get_status`
- [ ] `names` → `get_names`
- [ ] `user` → `get_profile`
- [x] `status` → `get_status`
- [x] `names` → `get_names`
- [x] `user` → `get_profile`

Improvements:
- [x] `get_uuid` returns the uuid
Expand Down
6 changes: 3 additions & 3 deletions mojang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from .api import (
get_uuid,
get_uuids,
names,
status,
user,
get_names,
get_status,
get_profile,
connect,
microsoft_app,
)
Expand Down
2 changes: 1 addition & 1 deletion mojang/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .base import status, get_uuid, get_uuids, names, user
from .base import get_status, get_uuid, get_uuids, get_names, get_profile
from .ext.session import connect
from .ext.microsoft import microsoft_app
14 changes: 7 additions & 7 deletions mojang/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
from .utils import helpers, urls


def status() -> StatusCheck:
def get_status() -> StatusCheck:
"""Get the status of Mojang's services
:Example:
>>> import mojang
>>> mojang.status()
>>> mojang.get_status()
(
ServiceStatus(name='minecraft.net', status='green'),
ServiceStatus(name='session.minecraft.net', status='green'),
Expand Down Expand Up @@ -107,15 +107,15 @@ def get_uuids(usernames: Iterable[str]) -> Dict[str, Optional[str]]:
return ret


def names(uuid: str) -> Optional[NameInfoList]:
def get_names(uuid: str) -> Optional[NameInfoList]:
"""Get the user's name history
:param str uuid: The user's uuid
:Example:
>>> import mojang
>>> mojang.names('65a8dd127668422e99c2383a07656f7a)
>>> mojang.get_names('65a8dd127668422e99c2383a07656f7a)
(
NameInfo(name='piewdipie', changed_to_at=None),
NameInfo(name='KOtMotros', changed_to_at=datetime.datetime(2020, 3, 4, 17, 45, 26))
Expand All @@ -139,15 +139,15 @@ def names(uuid: str) -> Optional[NameInfoList]:
return NameInfoList(_names)


def user(uuid: str) -> Optional[UnauthenticatedProfile]:
def get_profile(uuid: str) -> Optional[UnauthenticatedProfile]:
"""Returns the full profile of a user
:param str uuid: The uuid of the profile
:Example:
>>> import mojang
>>> mojang.user('069a79f444e94726a5befca90e38aaf5')
>>> mojang.get_profile('069a79f444e94726a5befca90e38aaf5')
UnauthenticatedProfile(
name='Notch',
uuid='069a79f444e94726a5befca90e38aaf5',
Expand Down Expand Up @@ -187,7 +187,7 @@ def user(uuid: str) -> Optional[UnauthenticatedProfile]:
uuid=uuid,
is_legacy=data.get("legacy", False),
is_demo=data.get("demo", False),
names=names(uuid),
names=get_names(uuid),
skin=skin,
cape=cape,
)
4 changes: 2 additions & 2 deletions mojang/api/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Unauthorized,
UnavailableName,
)
from .base import names
from .base import get_names
from .structures.profile import AuthenticatedUserProfile
from .structures.session import Cape, NameChange, Skin
from .utils import helpers, urls
Expand Down Expand Up @@ -231,7 +231,7 @@ def get_profile(access_token: str) -> AuthenticatedUserProfile:
uuid=data["id"],
is_legacy=False,
is_demo=False,
names=names(data["id"]),
names=get_names(data["id"]),
skins=skins,
capes=capes,
)
8 changes: 4 additions & 4 deletions tests/test_mojang_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

class TestMojangStatus(unittest.TestCase):
def setUp(self) -> None:
self.notch = mojang.names("069a79f444e94726a5befca90e38aaf5")
self.jeb_ = mojang.names("853c80ef3c3749fdaa49938b674adae6")
self.notch = mojang.get_names("069a79f444e94726a5befca90e38aaf5")
self.jeb_ = mojang.get_names("853c80ef3c3749fdaa49938b674adae6")

self.unkown = mojang.names("069a79f444e94726a5befca90e38aaf6")
self.unkown = mojang.get_names("069a79f444e94726a5befca90e38aaf6")

def test_existent_names(self):
self.assertEqual(self.notch, NameInfoList([NameInfo("Notch", None)]))
Expand All @@ -20,4 +20,4 @@ def test_unexistent_names(self):
self.assertEqual(self.unkown, None)

def test_invalid_names(self):
self.assertRaises(ValueError, mojang.names, "thisisnotauuid")
self.assertRaises(ValueError, mojang.get_names, "thisisnotauuid")
2 changes: 1 addition & 1 deletion tests/test_mojang_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TestMojangStatus(unittest.TestCase):
def setUp(self) -> None:
self.value = mojang.status()
self.value = mojang.get_status()

def test_status(self):
expected = StatusCheck(
Expand Down
8 changes: 4 additions & 4 deletions tests/test_mojang_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

class TestMojangStatus(unittest.TestCase):
def setUp(self) -> None:
self.notch = mojang.user("069a79f444e94726a5befca90e38aaf5")
self.jeb_ = mojang.user("853c80ef3c3749fdaa49938b674adae6")
self.unkown = mojang.user("069a79f444e94726a5befca90e38aaf6")
self.notch = mojang.get_profile("069a79f444e94726a5befca90e38aaf5")
self.jeb_ = mojang.get_profile("853c80ef3c3749fdaa49938b674adae6")
self.unkown = mojang.get_profile("069a79f444e94726a5befca90e38aaf6")

def test_existent_user(self):
self.assertEqual(
Expand Down Expand Up @@ -52,4 +52,4 @@ def test_unexistent_user(self):
self.assertEqual(self.unkown, None)

def test_invalid_user(self):
self.assertRaises(ValueError, mojang.user, "thisisnotauuid")
self.assertRaises(ValueError, mojang.get_profile, "thisisnotauuid")

0 comments on commit 45b0795

Please sign in to comment.