ticket query, and ticket purchase with tests