MCPcopy Create free account
hub / github.com/GCWing/BitFun / run_tests

Function run_tests

src/apps/relay-server/test_incremental_upload.py:128–335  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126
127
128async 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",

Callers 1

Calls 10

b64encFunction · 0.85
sha256hexFunction · 0.85
printFunction · 0.85
http_getFunction · 0.85
assert_eqFunction · 0.85
assert_containsFunction · 0.85
create_room_wsFunction · 0.85
http_post_jsonFunction · 0.85
getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected