|
|
@@ -68,7 +68,8 @@ async def _test(*clients): |
|
|
|
|
|
|
|
|
|
|
|
def test_happy_path(): |
|
|
|
client = _make_client('ws://TestUser@localhost:8642/A', 0.1, Script() |
|
|
|
client = _make_client('ws://localhost:8642/A', 0.1, Script() |
|
|
|
+ {'action': 'login', 'username': 'TestUser'} |
|
|
|
- {'kind': 'update', 'users': ['TestUser'], 'info': 'Welcome to /A', 'username': 'TestUser'} |
|
|
|
+ {'action': 'post', 'text': 'Hello World!'} |
|
|
|
- {'kind': 'post', 'source': 'TestUser', 'text': 'Hello World!'} |
|
|
@@ -77,14 +78,17 @@ def test_happy_path(): |
|
|
|
|
|
|
|
|
|
|
|
def test_name_taken(): |
|
|
|
client1 = _make_client('ws://A@localhost:8642/', 0.10, Script() |
|
|
|
client1 = _make_client('ws://localhost:8642/', 0.10, Script() |
|
|
|
+ {'action': 'login', 'username': 'A'} |
|
|
|
- {'kind': 'update', 'users': ['A'], 'info': 'Welcome to /', 'username': 'A'} |
|
|
|
- {'kind': 'update', 'users': ['A', 'B'], 'info': 'B joined'} |
|
|
|
) |
|
|
|
client2 = _make_client('ws://A@localhost:8642/', 0.11, Script() |
|
|
|
client2 = _make_client('ws://localhost:8642/', 0.11, Script() |
|
|
|
+ {'action': 'login', 'username': 'A'} |
|
|
|
- {'kind': 'error', 'info': 'Username taken'} |
|
|
|
) |
|
|
|
client3 = _make_client('ws://B@localhost:8642/', 0.12, Script() |
|
|
|
client3 = _make_client('ws://localhost:8642/', 0.12, Script() |
|
|
|
+ {'action': 'login', 'username': 'B'} |
|
|
|
- {'kind': 'update', 'users': ['A', 'B'], 'info': 'Welcome to /', 'username': 'B'} |
|
|
|
- {'kind': 'update', 'users': ['B'], 'info': 'A left'} |
|
|
|
) |
|
|
@@ -92,14 +96,16 @@ def test_name_taken(): |
|
|
|
|
|
|
|
|
|
|
|
def test_interact(): |
|
|
|
client1 = _make_client('ws://Alice@localhost:8642/', 0.10, Script() |
|
|
|
client1 = _make_client('ws://localhost:8642/', 0.10, Script() |
|
|
|
+ {'action': 'login', 'username': 'Alice'} |
|
|
|
- {'kind': 'update', 'users': ['Alice'], 'info': 'Welcome to /', 'username': 'Alice'} |
|
|
|
- {'kind': 'update', 'users': ['Alice', 'Bob'], 'info': 'Bob joined'} |
|
|
|
+ {'action': 'post', 'text': 'Hey Bob!'} |
|
|
|
- {'kind': 'post', 'source': 'Alice', 'text': 'Hey Bob!'} |
|
|
|
- {'kind': 'post', 'source': 'Bob', 'text': 'Howdy!'} |
|
|
|
) |
|
|
|
client2 = _make_client('ws://Bob@localhost:8642/', 0.11, Script() |
|
|
|
client2 = _make_client('ws://localhost:8642/', 0.11, Script() |
|
|
|
+ {'action': 'login', 'username': 'Bob'} |
|
|
|
- {'kind': 'update', 'users': ['Alice', 'Bob'], 'info': 'Welcome to /', 'username': 'Bob'} |
|
|
|
- {'kind': 'post', 'source': 'Alice', 'text': 'Hey Bob!'} |
|
|
|
+ {'action': 'post', 'text': 'Howdy!'} |
|
|
@@ -111,7 +117,8 @@ def test_interact(): |
|
|
|
|
|
|
|
|
|
|
|
def test_party(): |
|
|
|
client1 = _make_client('ws://Norman@localhost:8642/', 0.10, Script() |
|
|
|
client1 = _make_client('ws://localhost:8642/', 0.10, Script() |
|
|
|
+ {'action': 'login', 'username': 'Norman'} |
|
|
|
- {'kind': 'update', 'users': ['Norman'], 'info': 'Welcome to /', 'username': 'Norman'} |
|
|
|
- {'kind': 'update', 'users': ['Norman', 'Ray'], 'info': 'Ray joined'} |
|
|
|
- {'kind': 'update', 'users': ['Emma', 'Norman', 'Ray'], 'info': 'Emma joined'} |
|
|
@@ -119,14 +126,16 @@ def test_party(): |
|
|
|
- {'kind': 'post', 'source': 'Norman', 'text': 'なに?'} |
|
|
|
- {'kind': 'update', 'users': ['Norman', 'Ray'], 'info': 'Emma left'} |
|
|
|
) |
|
|
|
client2 = _make_client('ws://Ray@localhost:8642/', 0.11, Script() |
|
|
|
client2 = _make_client('ws://localhost:8642/', 0.11, Script() |
|
|
|
+ {'action': 'login', 'username': 'Ray'} |
|
|
|
- {'kind': 'update', 'users': ['Norman', 'Ray'], 'info': 'Welcome to /', 'username': 'Ray'} |
|
|
|
- {'kind': 'update', 'users': ['Emma', 'Norman', 'Ray'], 'info': 'Emma joined'} |
|
|
|
- {'kind': 'post', 'source': 'Norman', 'text': 'なに?'} |
|
|
|
- {'kind': 'update', 'users': ['Norman', 'Ray'], 'info': 'Emma left'} |
|
|
|
- {'kind': 'update', 'users': ['Ray'], 'info': 'Norman left'} |
|
|
|
) |
|
|
|
client3 = _make_client('ws://Emma@localhost:8642/', 0.12, Script() |
|
|
|
client3 = _make_client('ws://localhost:8642/', 0.12, Script() |
|
|
|
+ {'action': 'login', 'username': 'Emma'} |
|
|
|
- {'kind': 'update', 'users': ['Emma', 'Norman', 'Ray'], 'info': 'Welcome to /', 'username': 'Emma'} |
|
|
|
- {'kind': 'post', 'source': 'Norman', 'text': 'なに?'} |
|
|
|
) |
|
|
@@ -134,12 +143,14 @@ def test_party(): |
|
|
|
|
|
|
|
|
|
|
|
def test_rooms(): |
|
|
|
client1 = _make_client('ws://Dandy@localhost:8642/A', 0.10, Script() |
|
|
|
client1 = _make_client('ws://localhost:8642/A', 0.10, Script() |
|
|
|
+ {'action': 'login', 'username': 'Dandy'} |
|
|
|
- {'kind': 'update', 'users': ['Dandy'], 'info': 'Welcome to /A', 'username': 'Dandy'} |
|
|
|
+ {'action': 'post', 'text': 'Hi'} |
|
|
|
- {'kind': 'post', 'source': 'Dandy', 'text': 'Hi'} |
|
|
|
) |
|
|
|
client2 = _make_client('ws://Dandy@localhost:8642/B', 0.10, Script() |
|
|
|
client2 = _make_client('ws://localhost:8642/B', 0.10, Script() |
|
|
|
+ {'action': 'login', 'username': 'Dandy'} |
|
|
|
- {'kind': 'update', 'users': ['Dandy'], 'info': 'Welcome to /B', 'username': 'Dandy'} |
|
|
|
+ {'action': 'post', 'text': 'Howdy'} |
|
|
|
- {'kind': 'post', 'source': 'Dandy', 'text': 'Howdy'} |