def test_table_object_country(self): x = table_objects.country(1, "a") self.assertEqual(x.get_id() == 1, True) self.assertEqual(x.get_name() == "a", True) x.set_id(2) self.assertEqual(x.get_id() == 2, True) x.set_name("b") self.assertEqual(x.get_name() == "b", True)
def db_add_cheese(self, event): """ Handles adding cheese to database :return: returns nothing """ cheese_name = self.area1.get("1.0", 'end-1c').lower().encode('ascii', 'ignore') country_name = self.area2.get("1.0", 'end-1c').lower().encode('ascii', 'ignore') softness = self.area3.get("1.0", 'end-1c').lower().encode('ascii', 'ignore') cheese_to_add = None country_to_add = None if cheese_name != "": cheese_to_add = table_objects.cheese(-1, cheese_name, softness) db_func.add_cheese_row(self.db, cheese_to_add) if country_name != "": country_to_add = table_objects.country(-1, country_name) db_func.add_country_row(self.db, country_to_add) if cheese_to_add is not None and country_to_add is not None: db_func.connect_cheese_country(self.db, cheese_to_add, country_to_add) self.clean() self.columnconfigure(0, pad = 3, weight = 1) self.rowconfigure(0, pad = 3, weight = 1) self.rowconfigure(1, pad = 3, weight = 1) label = tk.Label(self, text = "Success!", font = ("Arial", 20), bg = "white") label.grid(row = 0, column = 0) back = ttk.Button(self, text = "Back", style = "Slate.TButton") back.grid(row = 1, column = 0, sticky = tk.N + tk.S + tk.E + tk.W) back.bind("<1>", self.main_menu) self.pack()
def db_add_cheese(self, event): """ Handles adding cheese to database :return: returns nothing """ cheese_name = self.area1.get("1.0", 'end-1c').lower().encode( 'ascii', 'ignore') country_name = self.area2.get("1.0", 'end-1c').lower().encode( 'ascii', 'ignore') softness = self.area3.get("1.0", 'end-1c').lower().encode('ascii', 'ignore') cheese_to_add = None country_to_add = None if cheese_name != "": cheese_to_add = table_objects.cheese(-1, cheese_name, softness) db_func.add_cheese_row(self.db, cheese_to_add) if country_name != "": country_to_add = table_objects.country(-1, country_name) db_func.add_country_row(self.db, country_to_add) if cheese_to_add is not None and country_to_add is not None: db_func.connect_cheese_country(self.db, cheese_to_add, country_to_add) self.clean() self.columnconfigure(0, pad=3, weight=1) self.rowconfigure(0, pad=3, weight=1) self.rowconfigure(1, pad=3, weight=1) label = tk.Label(self, text="Success!", font=("Arial", 20), bg="white") label.grid(row=0, column=0) back = ttk.Button(self, text="Back", style="Slate.TButton") back.grid(row=1, column=0, sticky=tk.N + tk.S + tk.E + tk.W) back.bind("<1>", self.main_menu) self.pack()