-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement api/player/autocomplete (#48) (client.users.get_by_autocomp…
…lete) * implement api/player/autocomplete * Autocomplete: rename `object`->`as_object` parameter and add optional `only_followed_players` parameter * rename `get_player_by_autocomplete` -> `get_by_autocomplete` * Implement test for `users.get_by_autocomplete` * fix readme, create changelog entry --------- Co-authored-by: Liaoshousan <[email protected]> Co-authored-by: kraktus <[email protected]>
- Loading branch information
1 parent
d607907
commit 8b8b8b0
Showing
13 changed files
with
286 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
tests/clients/cassettes/test_users/TestLichessGames.test_get_by_autocomplete.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/vnd.lichess.v3+json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- python-requests/2.31.0 | ||
method: GET | ||
uri: https://lichess.org/api/player/autocomplete?term=thisisatest&object=False&friend=False | ||
response: | ||
body: | ||
string: '["thisisatest","thisisatesty","thisisatest24","thisisatesttt","thisisatest333","thisisatest666","thisisatest1234","thisisatest8083","thisisatest12345","thisisatestlololol","thisisatestaccount13"]' | ||
headers: | ||
Access-Control-Allow-Headers: | ||
- Origin, Authorization, If-Modified-Since, Cache-Control, Content-Type | ||
Access-Control-Allow-Methods: | ||
- OPTIONS, GET, POST, PUT, DELETE | ||
Access-Control-Allow-Origin: | ||
- '*' | ||
Connection: | ||
- keep-alive | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Sat, 28 Oct 2023 17:17:24 GMT | ||
Permissions-Policy: | ||
- interest-cohort=() | ||
Server: | ||
- nginx | ||
Strict-Transport-Security: | ||
- max-age=63072000; includeSubDomains; preload | ||
Transfer-Encoding: | ||
- chunked | ||
Vary: | ||
- Origin | ||
X-Frame-Options: | ||
- DENY | ||
content-length: | ||
- '195' | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
48 changes: 48 additions & 0 deletions
48
tests/clients/cassettes/test_users/TestLichessGames.test_get_by_autocomplete_as_object.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/vnd.lichess.v3+json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- python-requests/2.31.0 | ||
method: GET | ||
uri: https://lichess.org/api/player/autocomplete?term=thisisatest&object=True&friend=False | ||
response: | ||
body: | ||
string: '{"result":[{"name":"Thisisatest","id":"thisisatest"},{"name":"thisisatesty","id":"thisisatesty"},{"name":"thisisatest24","id":"thisisatest24"},{"name":"Thisisatesttt","id":"thisisatesttt"},{"name":"thisisatest333","id":"thisisatest333"},{"name":"thisisatest666","id":"thisisatest666"},{"name":"Thisisatest1234","id":"thisisatest1234"},{"name":"thisisatest8083","id":"thisisatest8083"},{"name":"ThisIsATest12345","id":"thisisatest12345"},{"name":"thisisatestlololol","id":"thisisatestlololol"},{"name":"thisisatestaccount13","id":"thisisatestaccount13"}]}' | ||
headers: | ||
Access-Control-Allow-Headers: | ||
- Origin, Authorization, If-Modified-Since, Cache-Control, Content-Type | ||
Access-Control-Allow-Methods: | ||
- OPTIONS, GET, POST, PUT, DELETE | ||
Access-Control-Allow-Origin: | ||
- '*' | ||
Connection: | ||
- keep-alive | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Sat, 28 Oct 2023 17:17:23 GMT | ||
Permissions-Policy: | ||
- interest-cohort=() | ||
Server: | ||
- nginx | ||
Strict-Transport-Security: | ||
- max-age=63072000; includeSubDomains; preload | ||
Transfer-Encoding: | ||
- chunked | ||
Vary: | ||
- Origin | ||
X-Frame-Options: | ||
- DENY | ||
content-length: | ||
- '554' | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
46 changes: 46 additions & 0 deletions
46
...s/cassettes/test_users/TestLichessGames.test_get_by_autocomplete_as_object_not_found.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/vnd.lichess.v3+json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- python-requests/2.31.0 | ||
method: GET | ||
uri: https://lichess.org/api/player/autocomplete?term=username_not_found__&object=True&friend=False | ||
response: | ||
body: | ||
string: '{"result":[]}' | ||
headers: | ||
Access-Control-Allow-Headers: | ||
- Origin, Authorization, If-Modified-Since, Cache-Control, Content-Type | ||
Access-Control-Allow-Methods: | ||
- OPTIONS, GET, POST, PUT, DELETE | ||
Access-Control-Allow-Origin: | ||
- '*' | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '13' | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Sat, 28 Oct 2023 19:26:35 GMT | ||
Permissions-Policy: | ||
- interest-cohort=() | ||
Server: | ||
- nginx | ||
Strict-Transport-Security: | ||
- max-age=63072000; includeSubDomains; preload | ||
Vary: | ||
- Origin | ||
X-Frame-Options: | ||
- DENY | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
46 changes: 46 additions & 0 deletions
46
tests/clients/cassettes/test_users/TestLichessGames.test_get_by_autocomplete_not_found.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/vnd.lichess.v3+json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- python-requests/2.31.0 | ||
method: GET | ||
uri: https://lichess.org/api/player/autocomplete?term=username_not_found__&object=False&friend=False | ||
response: | ||
body: | ||
string: '[]' | ||
headers: | ||
Access-Control-Allow-Headers: | ||
- Origin, Authorization, If-Modified-Since, Cache-Control, Content-Type | ||
Access-Control-Allow-Methods: | ||
- OPTIONS, GET, POST, PUT, DELETE | ||
Access-Control-Allow-Origin: | ||
- '*' | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '2' | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Sat, 28 Oct 2023 19:26:34 GMT | ||
Permissions-Policy: | ||
- interest-cohort=() | ||
Server: | ||
- nginx | ||
Strict-Transport-Security: | ||
- max-age=63072000; includeSubDomains; preload | ||
Vary: | ||
- Origin | ||
X-Frame-Options: | ||
- DENY | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
|
||
from berserk import Client, OnlineLightUser | ||
from typing import List, Dict | ||
from utils import validate, skip_if_older_3_dot_10 | ||
|
||
|
||
class TestLichessGames: | ||
@skip_if_older_3_dot_10 | ||
@pytest.mark.vcr | ||
def test_get_by_autocomplete_as_object(self): | ||
res = Client().users.get_by_autocomplete("thisisatest", as_object=True) | ||
validate(List[OnlineLightUser], res) | ||
|
||
@skip_if_older_3_dot_10 | ||
@pytest.mark.vcr | ||
def test_get_by_autocomplete(self): | ||
res = Client().users.get_by_autocomplete("thisisatest") | ||
validate(List[str], res) | ||
|
||
@skip_if_older_3_dot_10 | ||
@pytest.mark.vcr | ||
def test_get_by_autocomplete_not_found(self): | ||
res = Client().users.get_by_autocomplete("username_not_found__") | ||
validate(List[str], res) | ||
|
||
@skip_if_older_3_dot_10 | ||
@pytest.mark.vcr | ||
def test_get_by_autocomplete_as_object_not_found(self): | ||
res = Client().users.get_by_autocomplete("username_not_found__", as_object=True) | ||
validate(List[OnlineLightUser], res) |
Oops, something went wrong.