Пример #1
0
def testCustomer():
    customer1 = customer("1", "12", "date", "10")
    customer2 = customer("2", "31", "date1", "11")
    customer3 = customer("3", "32", "date2", "14")
    customer4 = customer("4", "41", "date3", "100")

    assert customer1.returnCustomerId() == "1"
    assert customer2.returnCustomerId() == "2"
    assert customer3.returnCustomerId() == "3"
    assert customer4.returnCustomerId() == "4"

    assert customer1.returnCustomerName() == "12"
    assert customer2.returnCustomerName() == "31"
    assert customer3.returnCustomerName() == "32"
    assert customer4.returnCustomerName() == "41"

    assert customer1.returnCustomerCnp() == "date"
    assert customer2.returnCustomerCnp() == "date1"
    assert customer3.returnCustomerCnp() == "date2"
    assert customer4.returnCustomerCnp() == "date3"

    assert customer1.returnCustomerAdd() == "10"
    assert customer2.returnCustomerAdd() == "11"
    assert customer3.returnCustomerAdd() == "14"
    assert customer4.returnCustomerAdd() == "100"
Пример #2
0
 def add(self):
     print "add"
     phoneQuery = self.PhoneEntry.get()
     name = self.NameEntry.get()
     address = self.AddressEntry.get(1.0, tk.END)
     if self.db.checkExist(phoneQuery):
         if tkMessageBox.askyesno(self.AddText, self.UpdatePrompt):
             self.db.add(phoneQuery, customer(name, phoneQuery, address))
         else:
             self.search()
     else:
         self.db.add(phoneQuery, customer(name, phoneQuery, address))
Пример #3
0
 def createListCustomers(self):
     id=0
     while id<self.adjustedPossibleCustomers:
         id=id+1
         actualCustomer=customer.customer(id)
         actualCustomer.maxPrice=(float(actualCustomer.maxPrice)+(float(self.weather.temprature)/200))
         self.listCustomers.append(actualCustomer)
Пример #4
0
 def log_in (self):
     #print(self.login_password.get())
     self.c.execute("SELECT rowid FROM users WHERE login = ?", (str(self.login_username.get()),)) 
     if len(self.c.fetchall()) == 0:
         myLabel = Label(self.screen2, text = 'This user is not found ').pack()
     else:
         a = customer.customer(str(self.login_username.get()))
Пример #5
0
 def createListCustomers(self):
     id = 0
     while id < self.adjustedPossibleCustomers:
         id = id + 1
         actualCustomer = customer.customer(id)
         actualCustomer.maxPrice = (float(actualCustomer.maxPrice) +
                                    (float(self.weather.temprature) / 200))
         self.listCustomers.append(actualCustomer)
Пример #6
0
def test_invalid_customer_id_test(system):
    print('test invalid customer id test')
    cus1 = customer('')
    errors = system.create_order('')
    assert len(system.customer) == 0
    assert len(system.totalorder) == 0
    assert 'customer_id' in errors
    assert errors['customer_id'] == 'Detected a invalid customer id!'
Пример #7
0
def login():
    global cust
    global acc
    returnvalue = True
    cust_id = input("Enter Customer ID")
    password = input("Enter Password")
    con = cx_Oracle.connect('system/[email protected]/XE')
    cur = con.cursor()
    cur.execute(
        "SELECT * FROM customer_details where customer_no=:custid and cust_pass=:cust_pass",
        (cust_id, password))
    results = cur.fetchall()
    if (int(cur.rowcount) > 0):
        for row in results:
            f_name = row[1]
            l_name = row[2]
            addrline1 = row[3]
            addrline2 = row[4]
            pincode = row[5]
            city = row[6]

            cust = customer(cust_id, f_name, l_name, addrline1, addrline2,
                            pincode, city, password)
        print("Successfully login ")
        print("welcome " + f_name + " " + l_name)
        cur.execute("SELECT * FROM account where customer_no=:custid",
                    (cust_id))
        results = cur.fetchall()
        if (int(cur.rowcount) > 0):
            for row in results:
                acc_no = row[0]
                acc_type = row[1]
                openedDate = row[2]
                balance = row[3]
                closedDate = row[5]
                status = row[6]
            if (status == 'Active'):
                if (acc_type == 'saving'):
                    cur.execute(
                        "SELECT * FROM saving_account where acc_no=:accno",
                        (acc_no))
                    results = cur.fetchall()
                    if (int(cur.rowcount) > 0):
                        for row in results:
                            withdrawcount = row[1]
                        acc = savingaccount(openedDate, acc_no, balance,
                                            cust_id, withdrawcount)
                else:
                    acc = currentaccount(openedDate, acc_no, balance, cust_id)
            else:
                print('Your account is not active')
                returnvalue = False
    else:
        returnvalue = False
        print('wrong user name or password')
    con.commit()
    con.close()
    return returnvalue
Пример #8
0
def test_invalid_drinks_id_test(system):
    print('test invalid drinks id test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('', 'samll', 2)
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'drinks_foodid' in errors
    assert errors['drinks_foodid'] == 'Sorry, we do not have this drinks'
Пример #9
0
def test_invalid_drinks_size_test(system):
    print('test invalid drinks size test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', '', 2)
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'drinks_size' in errors
    assert errors['drinks_size'] == 'Please enter a correct size!'
Пример #10
0
def test_invalid_drinks_number_test(system):
    print('test invalid drinks number test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', '')
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'drinks_number' in errors
    assert errors['drinks_number'] == 'Please enter a correct number!'
Пример #11
0
def test_invalid_drinks_limit_test(system):
    print('test invalid drinks limit test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 100)
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'drinks_limit' in errors
    assert errors['drinks_limit'] == 'Sorry, exceed the maximum number!'
Пример #12
0
def test_invalid_drinks_inventory_test(system):
    print('test invalid drinks inventory test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('lift', 'large', 2)
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'drinks_inventory' in errors
    assert errors['drinks_inventory'] == 'Sorry, not enough inventory!'
Пример #13
0
 def loadFromXML(self):
     tree = ET.parse("db.xml")
     root = tree.getroot()
     for child in root:
         name = child[0].text
         phoneNumber = child[1].text
         address = child[2].text
         Customer = customer.customer(name, phoneNumber, address)
         self.add(phoneNumber, Customer)
Пример #14
0
 def create_order(self,customer_id):
     try:
         check_customer(customer_id)
     except OrderingError as error:
         return error.errors
     cus = customer(customer_id)
     self._orderid = self._orderid + 1
     self._totalorder.append(order(customer_id))
     self._customer.append(cus)
     return {}
Пример #15
0
def test_invalid_sides_inventory_test(system):
    print('test invalid sides inventory test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 2)
    errors = system.add_sides('springroll', 'large', 1)
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'sides_inventory' in errors
    assert errors['sides_inventory'] == 'Sorry, not enough inventory!'
Пример #16
0
def test_invalid_sides_id_test(system):
    print('test invalid sides id test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 2)
    errors = system.add_sides('', 'large', 1)
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'sides_foodid' in errors
    assert errors['sides_foodid'] == 'Sorry, we do not have this sides!'
Пример #17
0
def test_invalid_patties_limit_test(system):
    print('test invalid patties limit test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 2)
    errors = system.add_sides('fries', 'large', 1)
    errors = system.add_patties('fish_patties', 100)
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'patties_limit' in errors
    assert errors['patties_limit'] == 'Sorry, exceed the maximum number!'
Пример #18
0
def test_invalid_mains_type_test(system):
    print('test invalid mains type test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 2)
    errors = system.add_sides('fries', 'large', 1)
    errors = system.order_a_mains('')
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'mains_type' in errors
    assert errors['mains_type'] == 'Sorry, we do not have this mains!'
Пример #19
0
def test_invalid_sundaes_number_test(system):
    print('test invalid sundaes number test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 2)
    errors = system.add_sides('fries', 'large', 1)
    errors = system.add_sundaes('chocolate', 'large', '')
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'sundaes_number' in errors
    assert errors['sundaes_number'] == 'Please enter a correct number!'
Пример #20
0
def generator(CUST, seed, x, Q, Q2, Q3):
    for i in range(len(seed)):
    #for x in range(15):
        random.seed(seed[i])
        idx = random.randint(0, 5)
        CUST[x] = customer(x + 1, a[idx], order_count, maxN)  # ID = x+1, address = a[idx]
        CUST[x].makeRGB(seed[i])
        Q.put(CUST[x])
        Q2.put(CUST[x])
        Q3.put(CUST[x])
        x += 1
Пример #21
0
def add_customer_for_quote():
    print("Add a new customer for quote")
    print("----------------------------")
    firstname = input("Firstname: ")
    surname = input("Surname: ")
    town = input("Town: ")
    telephone = input("Telephone number: ")
    # Aha! What is this next line?
    customer1 = customer(firstname, surname, town, telephone)
    customer_list.append(customer1)
    #print("Customer successfully added.")
    return customer1
Пример #22
0
    def toLogin(self):
        em = self.email.text()
        pas = self.password.text()
        conn = pymysql.connect(host="localhost",user="******",password="",db="carRental")
        cur = conn.cursor()
        query = "SELECT `role` FROM `users` WHERE `email`=%s and `password`=%s"
        cur.execute(query, (em,pas))
        result = cur.fetchone()
        if result is None:
            msg = QMessageBox()
            # msg.setIcon(QMessageBox.Information)
            # msg.setText("Record doesn't exist in database")
            # msg.setInformativeText("This is additional information")
            # msg.setWindowTitle("Not Found")
            # msg.setDetailedText("The details are as follows:")
            msg.about(self,'Not Found',"Record doesn't exist in database, please sign-up")
        else:
            log= result[0]
            conn.close()
            if log==2:
                self.close()
                self.screen = adminAddCar.adminAddCar(em)
                self.screen.show()
            elif log==3:
                self.close()
                self.screen = driverSal.driverSal(em)
                self.screen.show()
            else:
                conn = pymysql.connect(host="localhost",user="******",password="",db="carRental")
                cur = conn.cursor()

                query = "SELECT `id` FROM `users` WHERE `email`=%s"
                cur.execute(query, (em))
                result = cur.fetchone()


                query = "SELECT `approve` FROM `books` WHERE `cu_id`=%s"
                cur.execute(query, result[0])
                result1 = cur.fetchone()
                conn.close()

                if result1[0]=="pending":
                    self.close()
                    self.screen = pending.pending()
                    self.screen.show()
                elif result1[0]=="Yes":
                    self.close()
                    self.screen = prebill.prebill(em)
                    self.screen.show()
                else:
                    self.close()
                    self.screen = customer.customer(em)
                    self.screen.show()
Пример #23
0
def test_invalid_patties_number_test(system):
    print('test invalid patties number test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 2)
    errors = system.add_sides('fries', 'large', 1)
    errors = system.order_a_mains('Buger')
    errors = system.add_patties('fish_patties', '')
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'patties_number' in errors
    assert errors['patties_number'] == 'Please enter a correct number!'
Пример #24
0
def main():
    print "THIS IS MAIN"
    db = database()
    flag = True
    while flag:
        action = raw_input(actionPrompt)
        if action == "exit":
            break
        elif action == "new":
            phoneNumber = raw_input(phonePrompt)
            if not db.checkExist(phoneNumber):
                name = raw_input(namePrompt)
                address = raw_input(addressPrompt)
                db.add(phoneNumber, customer(name, phoneNumber, address))
            else:
                print db.lookUp(phoneNumber)
        elif action == "search":
            phoneNumber = raw_input(phonePrompt)
            if not db.checkExist(phoneNumber):
                print invalidEntry
                addNew = raw_input(wishToAddPrompt)
                if addNew == "yes" or addNew == "y":
                    name = raw_input(namePrompt)
                    address = raw_input(addressPrompt)
                    db.add(phoneNumber, customer(name, phoneNumber, address))
                else:
                    continue
            else:
                print db.lookUp(phoneNumber)
        elif action == "delete":
            phoneNumber = raw_input(phonePrompt)
            if not db.checkExist(phoneNumber):
                print invalidEntry
                continue
            else:
                db.delete(phoneNumber)
        elif action == "save":
            db.storeDBXML()
        elif action == "load":
            db.loadDBXML()
Пример #25
0
 def add_new_reservation(self):
     a = self.hotel_name
     b = self.customer_name
     if (self.reserve_room(a, b)):
         #print('confirmation')
         number = input(
             'Please Enter Your Phone Number To Complete Confirmation  :')
         new_customer = customer.customer(b, number)
         #customer.customer.add_customer()
         self.send_text_message(number)
         print('Check Your Phone Please ')
     else:
         print('sorry no room available ')
Пример #26
0
def test_invalid_ingredient_inventory_test(system):
    print('test invalid ingredient inventory test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 2)
    errors = system.add_sides('fries', 'large', 1)
    errors = system.order_a_mains('Buger')
    errors = system.add_patties('fish_patties', 1)
    errors = system.add_ingredient('onions', 1)
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'ingredient_inventory' in errors
    assert errors['ingredient_inventory'] == 'Sorry, not enough inventory!'
Пример #27
0
def test_invalid_ingredient_id_test(system):
    print('test invalid ingredient id test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 2)
    errors = system.add_sides('fries', 'large', 1)
    errors = system.order_a_mains('Buger')
    errors = system.add_patties('fish_patties', 1)
    errors = system.add_ingredient('', 1)
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert 'ingredient_foodid' in errors
    assert errors['ingredient_foodid'] == 'Sorry, we do not have this ingredient!'
Пример #28
0
def test_successful_make_order2_test(system):
    print('test successful make order2 test')
    cus1 = customer(777)
    errors = system.create_order(777)
    errors = system.add_drinks('coca', 'large', 3)
    errors = system.add_sides('salad', 'small', 3)
    errors = system.order_a_mains('Buger')
    errors = system.add_patties('fish_patties', 1)
    errors = system.add_ingredient('tomato', 1)
    errors = system.add_buns(2)
    errors = system.add_mains
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    assert errors == {}
Пример #29
0
def signUp():
    print('in sign up')
    First_name = input("Enter First name")
    Last_name = input("Enter Last name")
    Address_line1 = input("Enter Your Address line 1")
    Address_line2 = input("Enter Your Address line 2")
    City = input("Enter your city")
    Pincode = input("Enter Pin code")
    Pincode = int(Pincode)
    # State = raw_input("Enter state")
    # Account_type = input("Enter account type 'saving / current / fixed deposit/ loan'")
    password = input("Enter password")
    cust = customer("0", First_name, Last_name, Address_line1, Address_line2,
                    Pincode, City, password)
    cust_id = cust.signUp()
Пример #30
0
def test_invalid_customer_id_test(system):
    print('test invalid customer id test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 2)
    errors = system.add_sides('fries', 'large', 1)
    errors = system.order_a_mains('Buger')
    errors = system.add_patties('fish_patties', 1)
    errors = system.add_ingredient('tomato', 1)
    errors = system.add_buns(2)
    errors = system.add_mains
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    errors = system.staff_serivce('', 'Preparing')
    assert 'customer_id' in errors
    assert errors['customer_id'] == 'Please enter a valid customer id!'
Пример #31
0
def test_invalid_updated_status_test(system):
    print('test invalid updated status test')
    cus1 = customer(666)
    errors = system.create_order(666)
    errors = system.add_drinks('coca', 'small', 2)
    errors = system.add_sides('fries', 'large', 1)
    errors = system.order_a_mains('Buger')
    errors = system.add_patties('fish_patties', 1)
    errors = system.add_ingredient('tomato', 1)
    errors = system.add_buns(2)
    errors = system.add_mains
    assert len(system.customer) == 1
    assert len(system.totalorder) == 1
    errors = system.staff_serivce(666, '')
    assert 'update_status' in errors
    assert errors['update_status'] == 'Please enter a valid status!'