def generate_ticket(self, values): vm = self.get_vending_machine() ticket_id = ticket.encode(vm.generate()) if not os.path.exists(self.eid): os.makedirs(self.eid) with file(self.get_ticket_filename(ticket_id), 'wb') as ticket_file: json.dump(values, ticket_file) return ticket_id
def test_encode_decode(self): for ticket_value in TICKET_VALUES: encoded = ticket.encode(ticket_value) decoded = ticket.decode(encoded) self.assertEquals(ticket_value, decoded)
def g(result, i): result[i] = ticket.encode(ticketing.gen())