def test_train_numpy_action(): request_queue = Queue(maxsize=1) response_queue = Queue(maxsize=1) response_queue.put_nowait( dict( action='Teleport', rotation=dict(y=np.array([24])[0]), moveMagnitude=np.array([55.5])[0], )) s = ai2thor.server.Server(request_queue, response_queue, '127.0.0.1') c = s.app.test_client() res = c.post( '/train', buffered=True, content_type= 'multipart/form-data; boundary=OVCo05I3SVXLPeTvCgJjHl1EOleL4u9TDx5raRVt', input_stream=BytesIO(generate_form(metadata_simple, s.sequence_id))) j = json.loads(res.get_data()) assert j == { 'action': 'Teleport', 'rotation': { 'y': 24 }, 'sequenceId': 1, 'moveMagnitude': 55.5 } assert res.status_code == 200
def test_train(): request_queue = Queue(maxsize=1) response_queue = Queue(maxsize=1) response_queue.put_nowait(dict(action='RotateRight')) s = ai2thor.server.Server(request_queue, response_queue, '127.0.0.1') c = s.app.test_client() res = c.post( '/train', buffered=True, content_type='multipart/form-data; boundary=OVCo05I3SVXLPeTvCgJjHl1EOleL4u9TDx5raRVt', input_stream=BytesIO(generate_form(metadata_simple, s.sequence_id))) assert res.status_code == 200
def test_non_multipart(): request_queue = Queue(maxsize=1) response_queue = Queue(maxsize=1) response_queue.put_nowait(dict(action='RotateRight')) s = ai2thor.server.Server(request_queue, response_queue, '127.0.0.1') c = s.app.test_client() s.client_token = '1234567' m = dict(agents=[metadata_simple], sequenceId=s.sequence_id) res = c.post('/train', data=dict(metadata=json.dumps(m), token=s.client_token)) assert res.status_code == 200
def server(): request_queue = Queue(maxsize=1) response_queue = Queue(maxsize=1) return ai2thor.server.Server(request_queue, response_queue, '127.0.0.1')