()
| 126 | |
| 127 | |
| 128 | async def run_tests(): |
| 129 | global PASS, FAIL |
| 130 | |
| 131 | ts = int(time.time()) |
| 132 | room1 = f"test_incr_{ts}_1" |
| 133 | room2 = f"test_incr_{ts}_2" |
| 134 | |
| 135 | # Test data |
| 136 | file1_content = "<html><body>Hello BitFun Test</body></html>" |
| 137 | file2_content = "body { margin: 0; background: #1a1a2e; }" |
| 138 | file3_content = "console.log('BitFun incremental upload test');" |
| 139 | |
| 140 | file1_b64 = b64enc(file1_content) |
| 141 | file2_b64 = b64enc(file2_content) |
| 142 | file3_b64 = b64enc(file3_content) |
| 143 | |
| 144 | file1_hash = sha256hex(file1_content) |
| 145 | file2_hash = sha256hex(file2_content) |
| 146 | file3_hash = sha256hex(file3_content) |
| 147 | |
| 148 | file1_size = len(file1_content) |
| 149 | file2_size = len(file2_content) |
| 150 | file3_size = len(file3_content) |
| 151 | |
| 152 | print("=" * 50) |
| 153 | print(" Incremental Upload Test Suite") |
| 154 | print(f" Relay: {RELAY_URL}") |
| 155 | print(f" WS: {WS_URL}") |
| 156 | print("=" * 50) |
| 157 | print() |
| 158 | |
| 159 | # ── [0] Health check ── |
| 160 | print("[0] Health check") |
| 161 | status, body = http_get(f"{RELAY_URL}/health") |
| 162 | assert_eq("Server is healthy", 200, status) |
| 163 | assert_contains("Response contains 'healthy'", body, "healthy") |
| 164 | print() |
| 165 | |
| 166 | print("Test files prepared:") |
| 167 | print(f" index.html hash={file1_hash[:12]}... size={file1_size}") |
| 168 | print(f" assets/style.css hash={file2_hash[:12]}... size={file2_size}") |
| 169 | print(f" assets/app.js hash={file3_hash[:12]}... size={file3_size}") |
| 170 | print() |
| 171 | |
| 172 | # ── [1] Create rooms ── |
| 173 | print("[1] Create rooms via WebSocket (kept alive)") |
| 174 | ws1, data1 = await create_room_ws(room1) |
| 175 | assert_eq(f"Room 1 ({room1}) created", "room_created", data1.get("type")) |
| 176 | |
| 177 | ws2, data2 = await create_room_ws(room2) |
| 178 | assert_eq(f"Room 2 ({room2}) created", "room_created", data2.get("type")) |
| 179 | print() |
| 180 | |
| 181 | try: |
| 182 | # ── [2] Legacy full upload ── |
| 183 | print("[2] Legacy full upload (upload-web) to Room 1") |
| 184 | status, resp = http_post_json( |
| 185 | f"{RELAY_URL}/api/rooms/{room1}/upload-web", |
no test coverage detected