def __init__(self): """ Initialise CarGUI class. """ # Data access object self.car_dao = CarDAO() # Validation object self.validator = Validation() # Form fields self.car_id = tk.StringVar() self.make = tk.StringVar() self.model = tk.StringVar() self.registration = tk.StringVar() self.manufacture_year = tk.StringVar() self.colour = tk.StringVar() # List of car ids self.lb_ids = None # Messagebox title self.mb_title_bar = "Car CRUD" pass
def test_find_ids(): """ Test the find_ids() method of the CarDAO class """ session = get_db_session() car_record = CarDAO() result = car_record.find_ids(session) print(result) session.close()
def test_find_by_make(): """ Test the find_by_make() method of the CarDAO class """ session = get_db_session() car_record = CarDAO() make = "tesla" result = car_record.find_by_make(session, make) print(result) session.close()
def test_delete(): """ Test the delete() method of the CarDAO class """ session = get_db_session() car_record = CarDAO() car_id = 1 result = car_record.delete(session, car_id) print(result) session.close()
def test_create(): """ Test the create() method of the CarDAO class """ session = get_db_session() car_record = CarDAO() data = { 'make': "Tesla", 'model': "Model X", 'registration': "ABC123", 'manufacture_year': 2018, 'colour': "black" } result = car_record.create(session, data) print(result) session.close()
def test_update(): """ Test the update() method of the CarDAO class """ session = get_db_session() car_record = CarDAO() car_id = 1 data = {} data['make'] = "Toyota" data['model'] = "Prius" data['registration'] = "XYZ999" data['manufacture_year'] = 2019 data['colour'] = "red" result = car_record.update(session, car_id, data) print(result) session.close()