-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbadaaa
commit e18ed11
Showing
12 changed files
with
221 additions
and
70 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from server import Team | ||
from pprint import pprint | ||
|
||
|
||
def test_info_user(): | ||
team = Team() | ||
name = "toto" | ||
serv, cli = team.run([f'/login "{name}"\n']) | ||
uuid = serv[0][1] | ||
serv, cli = team.run(['/info']) | ||
assert serv == None | ||
assert cli[0][0] == 'client_print_user' | ||
assert cli[0][1] == uuid | ||
assert cli[0][2] == 'toto' | ||
assert cli[0][3] == '1' | ||
|
||
def test_info_errors(): | ||
team = Team() | ||
name = "toto" | ||
serv, cli = team.run([f'/login "{name}"\n', "/logout"]) | ||
uuid = serv[0][1] | ||
serv, cli = team.run(['/info']) | ||
assert cli[1][0] == 'client_error_unauthorized' | ||
|
||
if __name__ == "__main__": | ||
# test_info_user() | ||
test_info_errors() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
from server import Team | ||
from pprint import pprint | ||
|
||
|
||
def test_user_single(): | ||
team = Team() | ||
name = "toto" | ||
serv, cli = team.run([ | ||
f'/login "{name}"\n', | ||
]) | ||
pprint(serv) | ||
pprint(cli) | ||
|
||
#login | ||
assert serv[0][0] == "server_event_user_created" | ||
uuid = serv[0][1] | ||
assert serv[0][2] == name | ||
|
||
assert cli[0][0] == "client_event_logged_in" | ||
assert cli[0][1] == uuid | ||
assert cli[0][2] == name | ||
|
||
#user | ||
serv, cli = team.run([ | ||
f'/user "{uuid}"\n', | ||
]) | ||
assert serv == None | ||
assert cli[0][0] == "client_print_user" | ||
assert cli[0][1] == uuid | ||
assert cli[0][2] == name | ||
assert cli[0][3] == '1' | ||
pprint(serv) | ||
pprint(cli) | ||
|
||
def test_user_not_logged(): | ||
team = Team() | ||
name = "toto" | ||
serv, cli = team.run([ | ||
f'/login "{name}"\n', | ||
f'/logout\n' | ||
]) | ||
pprint(serv) | ||
pprint(cli) | ||
|
||
#login | ||
assert serv[0][0] == "server_event_user_created" | ||
uuid = serv[0][1] | ||
assert serv[0][2] == name | ||
|
||
assert cli[0][0] == "client_event_logged_in" | ||
assert cli[0][1] == uuid | ||
assert cli[0][2] == name | ||
|
||
#user | ||
serv, cli = team.run([ | ||
f'/user "{uuid}"\n', | ||
]) | ||
pprint(serv) | ||
pprint(cli) | ||
|
||
assert serv[0][0] == "server_event_user_logged_out" | ||
assert serv[0][1] == uuid | ||
|
||
assert cli[0][0] == "client_event_logged_out" | ||
assert cli[0][1] == uuid | ||
assert cli[0][2] == name | ||
|
||
assert cli[1][0] == "client_error_unauthorized" | ||
|
||
def test_user_wrong(): | ||
team = Team() | ||
name = "toto" | ||
serv, cli = team.run([ | ||
f'/login "{name}"\n', | ||
]) | ||
pprint(serv) | ||
pprint(cli) | ||
|
||
#login | ||
assert serv[0][0] == "server_event_user_created" | ||
uuid = serv[0][1] | ||
assert serv[0][2] == name | ||
|
||
assert cli[0][0] == "client_event_logged_in" | ||
assert cli[0][1] == uuid | ||
assert cli[0][2] == name | ||
|
||
#user | ||
serv, cli = team.run([ | ||
f'/user "{"wrong uuid"}"\n', | ||
]) | ||
pprint(serv) | ||
pprint(cli) | ||
assert serv == None | ||
assert cli[0][0] == "client_error_unknown_user" | ||
assert cli[0][1] == "00000000-0000-0000-0000-000000000000" | ||
|
||
serv, cli = team.run([ | ||
f'/user\n', | ||
]) | ||
pprint(serv) | ||
pprint(cli) | ||
assert serv == None | ||
assert cli == None | ||
|
||
if __name__ == "__main__": | ||
# test_user_single() | ||
# test_user_not_logged() | ||
test_user_wrong() |