|
|
@@ -69,7 +69,7 @@ async def _test(*clients): |
|
|
|
|
|
|
|
|
|
|
|
def test_happy_path(): |
|
|
|
client = _make_client('ws://localhost:8642/A', 0.1, Script() |
|
|
|
client = _make_client('ws://localhost:8642/x', 0.1, Script() |
|
|
|
+ {'kind': 'login', 'value': 'TestUser'} |
|
|
|
- {'kind': 'state', 'username': 'TestUser'} |
|
|
|
- {'kind': 'state', 'online': ['TestUser']} |
|
|
@@ -80,17 +80,17 @@ def test_happy_path(): |
|
|
|
|
|
|
|
|
|
|
|
def test_name_taken(): |
|
|
|
client1 = _make_client('ws://localhost:8642/A', 0.10, Script() |
|
|
|
client1 = _make_client('ws://localhost:8642/x', 0.10, Script() |
|
|
|
+ {'kind': 'login', 'value': 'A'} |
|
|
|
- {'kind': 'state', 'username': 'A'} |
|
|
|
- {'kind': 'state', 'online': ['A']} |
|
|
|
- {'kind': 'state', 'online': ['A', 'B']} |
|
|
|
) |
|
|
|
client2 = _make_client('ws://localhost:8642/A', 0.11, Script() |
|
|
|
client2 = _make_client('ws://localhost:8642/x', 0.11, Script() |
|
|
|
+ {'kind': 'login', 'value': 'A'} |
|
|
|
- {'kind': 'error', 'value': 'Username taken'} |
|
|
|
) |
|
|
|
client3 = _make_client('ws://localhost:8642/A', 0.12, Script() |
|
|
|
client3 = _make_client('ws://localhost:8642/x', 0.12, Script() |
|
|
|
+ {'kind': 'login', 'value': 'B'} |
|
|
|
- {'kind': 'state', 'username': 'B'} |
|
|
|
- {'kind': 'state', 'online': ['A', 'B']} |
|
|
@@ -100,7 +100,7 @@ def test_name_taken(): |
|
|
|
|
|
|
|
|
|
|
|
def test_interaction(): |
|
|
|
client1 = _make_client('ws://localhost:8642/A', 0.10, Script() |
|
|
|
client1 = _make_client('ws://localhost:8642/x', 0.10, Script() |
|
|
|
+ {'kind': 'login', 'value': 'Alice'} |
|
|
|
- {'kind': 'state', 'username': 'Alice'} |
|
|
|
- {'kind': 'state', 'online': ['Alice']} |
|
|
@@ -109,7 +109,7 @@ def test_interaction(): |
|
|
|
- {'kind': 'post', 'value': 'Hey Bob!', 'source': 'Alice'} |
|
|
|
- {'kind': 'post', 'value': 'Howdy!', 'source': 'Bob'} |
|
|
|
) |
|
|
|
client2 = _make_client('ws://localhost:8642/A', 0.11, Script() |
|
|
|
client2 = _make_client('ws://localhost:8642/x', 0.11, Script() |
|
|
|
+ {'kind': 'login', 'value': 'Bob'} |
|
|
|
- {'kind': 'state', 'username': 'Bob'} |
|
|
|
- {'kind': 'state', 'online': ['Alice', 'Bob']} |
|
|
@@ -122,14 +122,14 @@ def test_interaction(): |
|
|
|
|
|
|
|
|
|
|
|
def test_rooms(): |
|
|
|
client1 = _make_client('ws://localhost:8642/A', 0.10, Script() |
|
|
|
client1 = _make_client('ws://localhost:8642/x', 0.10, Script() |
|
|
|
+ {'kind': 'login', 'value': 'Dandy'} |
|
|
|
- {'kind': 'state', 'username': 'Dandy'} |
|
|
|
- {'kind': 'state', 'online': ['Dandy']} |
|
|
|
+ {'kind': 'post', 'value': 'Hi', 'source': 'Dandy'} |
|
|
|
- {'kind': 'post', 'value': 'Hi', 'source': 'Dandy'} |
|
|
|
) |
|
|
|
client2 = _make_client('ws://localhost:8642/B', 0.10, Script() |
|
|
|
client2 = _make_client('ws://localhost:8642/y', 0.10, Script() |
|
|
|
+ {'kind': 'login', 'value': 'Dandy'} |
|
|
|
- {'kind': 'state', 'username': 'Dandy'} |
|
|
|
- {'kind': 'state', 'online': ['Dandy']} |
|
|
@@ -140,7 +140,7 @@ def test_rooms(): |
|
|
|
|
|
|
|
|
|
|
|
def test_private_message(): |
|
|
|
client1 = _make_client('ws://localhost:8642/A', 0.10, Script() |
|
|
|
client1 = _make_client('ws://localhost:8642/x', 0.10, Script() |
|
|
|
+ {'kind': 'login', 'value': 'Norman'} |
|
|
|
- {'kind': 'state', 'username': 'Norman'} |
|
|
|
- {'kind': 'state', 'online': ['Norman']} |
|
|
@@ -150,7 +150,7 @@ def test_private_message(): |
|
|
|
- {'kind': 'post', 'value': '1', 'source': 'Norman'} |
|
|
|
- {'kind': 'post', 'value': '3', 'source': 'Emma'} |
|
|
|
) |
|
|
|
client2 = _make_client('ws://localhost:8642/A', 0.11, Script() |
|
|
|
client2 = _make_client('ws://localhost:8642/x', 0.11, Script() |
|
|
|
+ {'kind': 'login', 'value': 'Ray'} |
|
|
|
- {'kind': 'state', 'username': 'Ray'} |
|
|
|
- {'kind': 'state', 'online': ['Norman', 'Ray']} |
|
|
@@ -160,7 +160,7 @@ def test_private_message(): |
|
|
|
- {'kind': 'post', 'value': '2', 'source': 'Ray'} |
|
|
|
- {'kind': 'state', 'online': ['Ray', 'Emma']} |
|
|
|
) |
|
|
|
client3 = _make_client('ws://localhost:8642/A', 0.12, Script() |
|
|
|
client3 = _make_client('ws://localhost:8642/x', 0.12, Script() |
|
|
|
+ {'kind': 'login', 'value': 'Emma'} |
|
|
|
- {'kind': 'state', 'username': 'Emma'} |
|
|
|
- {'kind': 'state', 'online': ['Norman', 'Ray', 'Emma']} |