def testDataRoute(self): """Tests that the /data route returns correct data for meshes.""" response = self.server.get( "/data/plugin/mesh/data?run=%s&tag=%s&sample=%d&content_type=%s" % (self.runs[0], self.names[0], 0, "VERTEX")) self.assertEqual(200, response.status_code) data = test_utils.deserialize_array_buffer_response( next(response.response), np.float32) vertices = np.tile(self.data[0].vertices.reshape(-1), self.steps) self.assertEqual(vertices.tolist(), data.tolist()) response = self.server.get( "/data/plugin/mesh/data?run=%s&tag=%s&sample=%d&content_type=%s" % (self.runs[0], self.names[1], 0, "FACE")) self.assertEqual(200, response.status_code) data = test_utils.deserialize_array_buffer_response( next(response.response), np.int32) faces = np.tile(self.data[1].faces.reshape(-1), self.steps) self.assertEqual(faces.tolist(), data.tolist()) response = self.server.get( "/data/plugin/mesh/data?run=%s&tag=%s&sample=%d&content_type=%s" % (self.runs[0], self.names[2], 0, "COLOR")) self.assertEqual(200, response.status_code) data = test_utils.deserialize_array_buffer_response( next(response.response), np.uint8) colors = np.tile(self.data[2].colors.reshape(-1), self.steps) self.assertListEqual(colors.tolist(), data.tolist())
def validate_data_response( self, run, tag, sample, content_type, dtype, ground_truth_data, step=0 ): """Makes request and checks that response has expected data.""" response = self.server.get( "/data/plugin/mesh/data?run=%s&tag=%s&sample=%d&content_type=" "%s&step=%d" % (run, tag, sample, content_type, step) ) self.assertEqual(200, response.status_code) data = test_utils.deserialize_array_buffer_response( next(response.response), dtype ) self.assertEqual(ground_truth_data.reshape(-1).tolist(), data.tolist())