Пример #1
0
def main():
    print('Customer 1')
    email = input('Enter email address: ')
    customer1 = Customer(email)
    customer1.input_info()
    customer1.verify_info()
    output_file = open('customers.txt', 'w')
    output = customer1.__str__()
    output_file.write(output)

    print('Customer 2')
    email = input('Enter email address: ')
    customer2 = Customer(email)
    customer2.input_info()
    customer2.verify_info()
    output_file = open('customers.txt', 'a')
    output = customer2.__str__()
    output_file.write(output)
    print("Data of two customers written to the file 'customers.txt'.")
Пример #2
0
class TestCriticalFunctions(unittest.TestCase):
    
    def test_customer(self):
        self.customer = Customer("Matti Mallikas","Abc 1 00000 Helsinki","0440000000","*****@*****.**"  )
        self.teststring = "Matti Mallikas, Abc 1 00000 Helsinki, 0440000000, [email protected]"
        self.assertEqual(self.customer.__str__(), self.teststring)
    
    #Yksikkötesti kesken
    def test_FailReservation(self):
        self.list1 = []
        self.list2 = []        
        self.calendar = Calendar()
        self.room = Room(2, 2, 60.99)
        self.list1.append(self.room)
        self.hotel = Hotel("Test Hotel",self.list1, self.list2, self.calendar)
        self.cust = self.hotel.add_customer("Matti Mallikas","Abc 1 00000 Helsinki","0440000000","*****@*****.**" )
        self.reservation1 = self.hotel.make_reservation(self.cust, "Room", "15.5.2019", "2")
Пример #3
0
class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.Cust1 = Customer("Smith", "John", "555-123-5555", 1200)

    def tearDown(self):
        del self.Cust1

    def test_cust_id(self):
        self.assertEqual(self.Cust1.customer_id, 1200)

    def test_last_name(self):
        self.assertEqual(self.Cust1.last_name, "Smith")

    def test_first_name(self):
        self.assertEqual(self.Cust1.first_name, "John")

    def test_phone_number(self):
        self.assertEqual(self.Cust1.phone_number, "555-123-5555")

    def test_bad_cust_id(self):
        with self.assertRaises(Exception):
            self.Cust1 = Customer("Smith", "John", "555-123-5555", 12)

    def test_bad_last_name(self):
        with self.assertRaises(Exception):
            self.Cust1 = Customer("Sm99ith", "John", "555-123-5555", 1200)

    def test_bad_first_name(self):
        with self.assertRaises(Exception):
            self.Cust1 = Customer("Smith", "Jo99hn", "555-123-5555", 1200)

    def test_bad_phone_number(self):
        with self.assertRaises(Exception):
            self.Cust1 = Customer("Smith", "John", "555123-5555", 1200)

    def test_str(self):
        self.assertEqual(
            self.Cust1.__str__(),
            "Customer Id: 1200, first name John, last name Smith, Phone:555-123-5555"
        )
Пример #4
0
 def add_customer(self, name, adress, number, email):
     customer = Customer(name, adress, number, email)
     self.customers.append(customer)
     self.customer_names.append(name)
     self.save(customer.__str__())
     return customer