Exemplo n.º 1
0
	def test_can_update_false(self):
		"""
		testing to see if you can update active status to false
		"""
		Customer_db().update_active_false()
		new_customers_again = Customer_db.get_all_customers()
		for customer in new_customers_again:
			self.assertEqual(0, customer[7])
Exemplo n.º 2
0
	def test_can_return_active(self):
		"""
		testing to see if you can return a customer with active set to true
		"""
		Customer_db().update_active_false()
		Customer_db().update_active_true(2)
		customer = Customer_db.get_active()
		active_status = customer[0][7]
		self.assertEqual(1, active_status)
Exemplo n.º 3
0
	def test_can_update_true(self):
		"""
		testing to see if you can update active status to true
		"""
		customers = Customer_db.get_all_customers()
		customer_id = customers[1][0]
		Customer_db().update_active_true(customer_id)
		new_customers = Customer_db.get_all_customers()
		active_status = new_customers[1][7]
		self.assertEqual(1, active_status)
Exemplo n.º 4
0
	def test_can_customer_be_saved_and_returned(self):
		"""
		testing to see if a customer can be saved to database and returned
		"""
		Customer_db().save_new_customer(self.me)
		data = Customer_db.get_all_customers()
		dataList = len(data)
		targetData = data[dataList -1]
		dummyTestData = (dataList, "Me", "500 interstate blvd", "Nashville", "TN", 11111, "666-6666", 0)
		self.assertTupleEqual(dummyTestData, targetData)
    def setUpClass(self):
        """
		 Create an instance of the product_p that can be used in all tests
		"""
        self.product_p = product_cli.ProductPopularity()
        self.orders_all = OrderDB.get_all_orders(self)
        self.customer_all = Customer_db.get_all_customers()
        self.prod_all = ProductData.get_all_products(self)
        self.line_item_all = LineItemDB.get_all_line_items(self)
Exemplo n.º 6
0
    def run(self):
        """
        This method prompts the user to make selections which will navigate
         them to different interfaces to access the functionality of the
          Bangazon CLI. Users also have the option of exiting the program
           altogether.
        """

        # Set all customers as inactive to start the program
        customer_db = Customer_db()
        customer_db.update_active_false()

        # while running == True, MainMenu loop will run repeatedly.
        # To leave Bangazon, running is set to False
        running = True

        # starts the main loop, which handles all CLI functionality and acts
        # as the control hub for the other modules
        while running:
            print("""\n\n\n\n\n\n""")
            print(BColor.stars + "{:*^54}".format("*") + BColor.ENDC)
            print(BColor.stars + "**" + BColor.ENDC +
                  "Welcome to Bangazon! Command Line Ordering System" +
                  BColor.stars + "**" + BColor.ENDC)
            print(BColor.stars + "{:*^54}".format("*") + BColor.ENDC)
            selected_option = input("""
1. Create a customer account
2. Choose active customer
3. Create a payment option
4. Add product to shopping cart
5. Complete an order
6. See product popularity
7. Leave Bangazon!
>""")

            if selected_option == "1":
                create_customer = CustomerCreation()
                create_customer.run()
            elif selected_option == "2":
                choose_customer = CustomerSelection()
                choose_customer.run()
            elif selected_option == "3":
                payment_create = PaymentSelection()
                payment_create.run()
            elif selected_option == "4":
                add_item = ShoppingCartCLI()
                add_item.add_line_item()
            elif selected_option == "5":
                add_item = ShoppingCartCLI()
                add_item.pay_for_cart()
            elif selected_option == "6":
                product_pop = ProductPopularity()
                product_pop.run()
            elif selected_option == "7":
                print("goodbye")
                customer_db.update_active_false()
                running = False
Exemplo n.º 7
0
    def run(self):
        """
        PaymentSelection.run() method prompts the user to enter their payment type and account number information. The payment information is then saved to the database.
        """
        print("""\n\n\n\n\n\n""")

        try:
            customer_on_payment = Customer_db.get_active()[0]
            customer_id = customer_on_payment[0]

            print("Enter payment" + BColor.blue_type + BColor.bold + " type " +
                  BColor.end_color + "(Visa, Mastercard, etc.):")
            payment_type = input(BColor.arrows + "> " + BColor.end_color)
            print("You entered", payment_type)

            print("Enter account number:")
            account_number = input(BColor.arrows + "> " + BColor.end_color)
            print("You entered", account_number)

            pay = Payment(payment_type, account_number, customer_id)
            PaymentDatabaseInteractor().save_payment(pay)
        except:
            print("Please choose an active customer")
    def run(self):
        """
        CustomerSelection.run() method prompts the user to select a customer 
        from a list of customers. This customer is then set as the active 
        customer by first making a call to the database to make sure that no 
        other customers are active. It then makes a call to the database to 
        set the selected customer as active.
        """

        # create an instance of the customer database interactor
        customer_db = Customer_db()

        # retrieve a list of customers
        all_customers = Customer_db.get_all_customers()
        
        # print the options to the command line and wait for the user to
        # select one
        print("""\n\n\n\n\n\n""")
        print("Which customer will be active?")
        for index, customer in enumerate(all_customers):
            print("{}. {}".format(index + 1, customer[1]))
        selection_index = input(">")

        # take the user selection and, if it's a valid option, update the 
        # database to reflect that customer as the active customer
        try:
            customer_index = int(selection_index) - 1
            if customer_index >= 0: 
                if customer_index < len(all_customers):
                    selected_customer = all_customers[customer_index]
                    selected_customer_id = selected_customer[0]
                    customer_db.update_active_false()
                    customer_db.update_active_true(selected_customer_id)

        except Exception as e:
            print("Invalid customer selection")