def courier_menu(): app_utilities.app_title() option = app_menu_displays.courier_menu_display() if option == '1': app_utilities.app_title() app_databases.print_table_function('couriers', f'SELECT * FROM couriers') input('\nPress Enter to continue. ') courier_menu() elif option == '2': app_utilities.app_title() app_databases.add_to_database_function('couriers') courier_menu() elif option == '3': app_utilities.app_title() app_databases.update_database_function('couriers') courier_menu() elif option == '4': app_utilities.app_title() app_databases.remove_database_function('couriers') courier_menu() elif option == '5': main_menu() elif option == '6': app_functions.exit_app() else: app_functions.incorrect_input() time.sleep(1) product_menu()
def test_cancel_remove_an_order_from_a_database_function( self, mock_execute, mock_existing_id, mock_get_column): table = 'orders' mock_get_column.return_value = ['order_id', 'customer_name'] mock_existing_id.return_value = '0' remove_database_function(table) self.assertEqual(mock_execute.call_count, 0)
def test_remove_from_couriers_database_function(self, mock_execute, mock_existing_id, mock_get_column): table = 'couriers' mock_get_column.return_value = ['courier_id', 'courier_name'] mock_existing_id.return_value = '1' expected = 'DELETE FROM couriers WHERE courier_id = 1' remove_database_function(table) mock_execute.assert_called_with(expected)
def test_raise_error_remove_an_order_from_a_database( self, mock_print, mock_execute, mock_existing_id, mock_get_column): table = 'couriers' mock_get_column.return_value = ['courier_id', 'courier_name'] mock_existing_id.return_value = '1' mock_execute.side_effect = pymysql.err.IntegrityError remove_database_function(table) mock_print.assert_called_with( '\nCannot delete something that is already in an existing order. Returning to previous screen.' )
def test_remove_an_order_from_a_database(self, mock_execute, mock_existing_id, mock_get_column): table = 'orders' mock_get_column.return_value = ['order_id', 'customer_name'] mock_existing_id.return_value = '1' expected = 'DELETE FROM orders WHERE order_id = 1' remove_database_function(table) mock_execute.assert_called_with(expected) self.assertEqual(mock_execute.call_count, 2)
def test_remove_from_product_database_function(self, mock_execute, mock_existing_id, mock_get_column): table = 'products' mock_get_column.return_value = [ 'product_id', 'product_name', 'product_price' ] mock_existing_id.return_value = '1' expected = 'DELETE FROM products WHERE product_id = 1' remove_database_function(table) mock_execute.assert_called_with(expected)
def order_menu(): app_utilities.app_title() option = app_menu_displays.order_menu_display() if option == '1': app_utilities.app_title() app_databases.print_table_function('orders', f'SELECT * FROM orders') print('\nTo see the products ordered for a customer,\n') id = app_databases.choose_an_existing_id('orders') if id == '0': order_menu() print('') customer_order = app_databases.read_from_database(f'SELECT p.product_id, p.product_name, p.product_price FROM customer_orders c JOIN products p ON c.product_id = p.product_id WHERE c.order_id = {id}') app_databases.print_order_table(customer_order) input('\nPress Enter to continue.') order_menu() elif option == '2': app_utilities.app_title() app_databases.add_to_database_function('orders') order_menu() elif option == '3': app_utilities.app_title() app_databases.update_order_status() order_menu() elif option == '4': app_utilities.app_title() app_databases.update_database_function('orders') order_menu() elif option == '5': app_utilities.app_title() app_databases.update_basket() order_menu() elif option == '6': app_utilities.app_title() app_databases.remove_database_function('orders') order_menu() elif option == '7': main_menu() elif option == '8': app_functions.exit_app() else: app_functions.incorrect_input() time.sleep(1) order_menu()