|
| 1 | +import uuid |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | + |
| 6 | +@pytest.fixture |
| 7 | +def status_name(): |
| 8 | + return "test_status_" + str(uuid.uuid1()).replace("-", "")[:12] |
| 9 | + |
| 10 | + |
| 11 | +@pytest.fixture |
| 12 | +def created_status(logged_rocket, status_name): |
| 13 | + result = logged_rocket.custom_user_status_create( |
| 14 | + name=status_name, status_type="online" |
| 15 | + ) |
| 16 | + status = result.get("customUserStatus") |
| 17 | + assert status is not None |
| 18 | + |
| 19 | + yield status |
| 20 | + |
| 21 | + logged_rocket.custom_user_status_delete(custom_user_status_id=status["_id"]) |
| 22 | + |
| 23 | + |
| 24 | +def test_custom_user_status_list(logged_rocket, created_status): |
| 25 | + result = logged_rocket.custom_user_status_list() |
| 26 | + assert "statuses" in result |
| 27 | + found = any(s["_id"] == created_status["_id"] for s in result["statuses"]) |
| 28 | + assert found |
| 29 | + |
| 30 | + |
| 31 | +def test_custom_user_status_create_delete(logged_rocket): |
| 32 | + name = "test_status_" + str(uuid.uuid1()).replace("-", "")[:12] |
| 33 | + result = logged_rocket.custom_user_status_create(name=name, status_type="busy") |
| 34 | + status = result.get("customUserStatus") |
| 35 | + assert status is not None |
| 36 | + assert status["name"] == name |
| 37 | + assert status["statusType"] == "busy" |
| 38 | + |
| 39 | + logged_rocket.custom_user_status_delete(custom_user_status_id=status["_id"]) |
| 40 | + |
| 41 | + statuses = logged_rocket.custom_user_status_list().get("statuses", []) |
| 42 | + assert not any(s["_id"] == status["_id"] for s in statuses) |
| 43 | + |
| 44 | + |
| 45 | +def test_custom_user_status_update(logged_rocket, created_status): |
| 46 | + new_name = created_status["name"] + "_upd" |
| 47 | + result = logged_rocket.custom_user_status_update( |
| 48 | + custom_user_status_id=created_status["_id"], |
| 49 | + name=new_name, |
| 50 | + status_type="away", |
| 51 | + ) |
| 52 | + updated = result.get("customUserStatus") |
| 53 | + assert updated is not None |
| 54 | + assert updated["name"] == new_name |
| 55 | + assert updated["statusType"] == "away" |
| 56 | + |
| 57 | + |
| 58 | +def test_custom_user_status_create_all_types(logged_rocket): |
| 59 | + created_ids = [] |
| 60 | + for status_type in ("online", "busy", "away", "offline"): |
| 61 | + name = "test_" + status_type + "_" + str(uuid.uuid1()).replace("-", "")[:8] |
| 62 | + result = logged_rocket.custom_user_status_create( |
| 63 | + name=name, status_type=status_type |
| 64 | + ) |
| 65 | + status = result.get("customUserStatus") |
| 66 | + assert status is not None |
| 67 | + assert status["statusType"] == status_type |
| 68 | + created_ids.append(status["_id"]) |
| 69 | + |
| 70 | + for sid in created_ids: |
| 71 | + logged_rocket.custom_user_status_delete(custom_user_status_id=sid) |
0 commit comments