Miro
3 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
12 additions and
2 deletions
-
steam/steamid.py
-
tests/test_steamid.py
|
|
@ -501,7 +501,7 @@ def from_csgo_friend_code(code, universe=EUniverse.Public): |
|
|
:return: SteamID instance |
|
|
:return: SteamID instance |
|
|
:rtype: :class:`.SteamID` or :class:`None` |
|
|
:rtype: :class:`.SteamID` or :class:`None` |
|
|
""" |
|
|
""" |
|
|
if not re.match(r'^['+_csgofrcode_chars+'\-]{10}$', code): |
|
|
if not re.match(r'^['+_csgofrcode_chars+r'\-]{10}$', code): |
|
|
return None |
|
|
return None |
|
|
|
|
|
|
|
|
code = ('AAAA-' + code).replace('-', '') |
|
|
code = ('AAAA-' + code).replace('-', '') |
|
|
@ -574,7 +574,7 @@ def steam64_from_url(url, http_timeout=30): |
|
|
# group profiles |
|
|
# group profiles |
|
|
else: |
|
|
else: |
|
|
text = web.get(match.group('clean_url'), timeout=http_timeout).text |
|
|
text = web.get(match.group('clean_url'), timeout=http_timeout).text |
|
|
data_match = re.search("OpenGroupChat\( *'(?P<steamid>\d+)'", text) |
|
|
data_match = re.search(r"OpenGroupChat\( *'(?P<steamid>\d+)'", text) |
|
|
|
|
|
|
|
|
if data_match: |
|
|
if data_match: |
|
|
return int(data_match.group('steamid')) |
|
|
return int(data_match.group('steamid')) |
|
|
|
|
|
@ -337,6 +337,16 @@ class steamid_functions(unittest.TestCase): |
|
|
mm.get.side_effect = requests.exceptions.ReadTimeout('test') |
|
|
mm.get.side_effect = requests.exceptions.ReadTimeout('test') |
|
|
self.assertIsNone(steamid.steam64_from_url("https://steamcommunity.com/id/timeout_me")) |
|
|
self.assertIsNone(steamid.steam64_from_url("https://steamcommunity.com/id/timeout_me")) |
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('steam.steamid.make_requests_session') |
|
|
|
|
|
def test_steam64_from_url_group_chat_markup(self, mrs_mock): |
|
|
|
|
|
mm = mrs_mock.return_value = mock.MagicMock() |
|
|
|
|
|
mm.get.return_value.text = "OpenGroupChat( '103582791429521412'" |
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual( |
|
|
|
|
|
steamid.steam64_from_url("https://steamcommunity.com/groups/Valve"), |
|
|
|
|
|
103582791429521412 |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
def test_steam64_from_url(self): |
|
|
def test_steam64_from_url(self): |
|
|
def scrub_req(r): |
|
|
def scrub_req(r): |
|
|
r.headers.pop('Cookie', None) |
|
|
r.headers.pop('Cookie', None) |
|
|
|