class TestEmployeeCreation(unittest.TestCase):
    def setUp(self):
        '''
    Creates re-usable cases for tests that follow
    '''
        self.emp_1 = Employee("Kostas", "Koutoupis", 30000, 3)
        self.emp_2 = Employee("Sue", "Weatherspoon", 20000, 2)

    def test_employee_fullname(self):
        '''
    Fullname method should combine employee's first and last name
    '''
        emp_1_fullname = self.emp_1.fullname
        self.assertEqual(emp_1_fullname, "Kostas Koutoupis")

        emp_2_fullname = self.emp_2.fullname
        self.assertEqual(self.emp_2.fullname, "Sue Weatherspoon")

    def test_employee_email(self):
        '''
    Email method should combine lastname and uppercase of
    first name's first letter with @company.uk
    '''
        email1 = self.emp_1.email
        self.assertEqual(email1, "*****@*****.**")

        email2 = self.emp_2.email
        self.assertEqual(email2, "*****@*****.**")

    def test_employee_email_regex(self):
        '''
    Testing email structure against regex
    '''
        email1 = self.emp_1.email
        self.assertRegex(email1, r"[\w]+[\w]@company\.uk")

        email2 = self.emp_2.email
        self.assertRegex(email2, r"[\w]+[\w]@company\.uk")

    def test_employee_apply_raise(self):
        '''
    Apply raise should multiply pay with raise amount
    '''
        raise_emp_1 = self.emp_1.apply_raise()
        self.assertEqual(raise_emp_1, 45000)

        raise_emp_2 = self.emp_2.apply_raise()
        self.assertEqual(raise_emp_2, 30000)

    def test_employee_can_be_promoted(self):
        '''
    If employee years in the company > 2
    then this should return True
    '''
        promotion_1 = self.emp_1.can_be_promoted()
        self.assertTrue(promotion_1)

        promotion_2 = self.emp_2.can_be_promoted()
        self.assertFalse(promotion_2)
 def test_employee_register_time(self):
     empl = Employee("Rafał", "Korzeniewski", 100.0)
     empl.register_time(5)
     assert empl.registered_time_normal == 5
     empl.register_time(10)
     assert empl.registered_time_normal == 8 + 5
     assert empl.registered_time_overtime == 2
     assert empl.registered_time_overtime == 2
Example #3
0
"""
File: test_company.py
This is the test program for assignment 4.
"""

from company import Employee, Customer

customer1 = Customer("Drew Smith", \
                   "285 Andover Lane, Pompano Beach, FL, 33060", \
                   "412-555-2121", \
                   760)

employees = []
employees.append(Employee("James Chen", \
                   "87 Pierce Road, Windsor, CT, 06095", \
                   "256-555-3331", \
                   907, \
                   75000)
                 )

employees.append(Employee("Brady Parker", \
                   "80 Franklin Dr., Waterbury, CT, 06705", \
                   "756-555-3828", \
                   321, \
                   90000)
                 )

print("Customers: \n")
print(customer1, "\n")

print("Employees: \n")
Example #4
0
while True:
    print(
        "\n \n what would you like to see:\n1.salary\n2.disp_details\n3.check\n4.calc_tax\n5.Exit"
    )
    choice = int(input("enter your choice: "))
    print(choice)
    sup_id = [12, 13, 14, 15, 16, 17]
    emp_name = raw_input("enter the name: ")
    emp_id = int(input("enter the id: "))
    emp_age = int(input("enter the age: "))
    emp_salary = int(input("enter the salary: "))

    if emp_id in sup_id:
        sup = Supervisor(emp_name, emp_id, emp_age, emp_salary)
    else:
        emp = Employee(emp_name, emp_id, emp_age, emp_salary)

    if choice == 1:
        months = int(input("enter number of months: "))
        if emp_id in sup_id:
            tot_salary = sup.salary(months)
            print(tot_salary)
        else:
            tot_salary = emp.salary(months)
            print(tot_salary)

    elif choice == 2:
        if emp_id in sup_id:
            sup.disp_details()
        else:
            emp.disp_details()
 def setUp(self):
     '''
 Creates re-usable cases for tests that follow
 '''
     self.emp_1 = Employee("Kostas", "Koutoupis", 30000, 3)
     self.emp_2 = Employee("Sue", "Weatherspoon", 20000, 2)
Example #6
0
Date: 3/29/2020

This file is a test program for the fuctions in company.py and person.py
"""

from company import Employee, Customer

customer1 = Customer("Andrew Coltor", \
                   "365 Jacob's Lane, Denver, CO, 33090", \
                   "661-555-2255", \
                   781)

employees = []
employees.append(Employee("James Chen", \
                   "99 Moulton Ave, Providence, RI, 07654", \
                   "504-555-6548", \
                   907, \
                   77000)
                 )

employees.append(Employee("Brady Parker", \
                   "66 Alberto Dr., Hartford, CT, 06963", \
                   "851-555-7913", \
                   321, \
                   91000)
                 )

print("Customers: \n")  #print customer information
print(customer1, "\n")

print("Employees: \n")  #print employee information
Example #7
0
from company import Employee

# Create employee, and give a default bonus (1%).
emp1 = Employee("Siv", 7000)		
emp1.payBonus();
print(emp1.toString())

# Create employee, and give a 10% bonus.
emp2 = Employee("Joe", 15000)		
emp2.payBonus(10);
print(emp2.toString())

# Increase the minimum salary.
Employee.setMinimumSalary(18000)

# Create employee, and give a 10% bonus if salary between 10000 and 20000.
emp3 = Employee("Adi", 15000)		
emp3.payBonus(10, 10000, 20000)
print(emp3.toString())

# Create employee, and give a 10% bonus if salary between 50000 and 80000.
emp4 = Employee("Ole", 15000)
emp4.payBonus(10, 50000, 80000)
print(emp4.toString())

 def test_employee_init(self):
     empl = Employee("Rafał", "Korzeniewski", 100.0)
     assert empl.first_name == "Rafał"
     assert empl.last_name == "Korzeniewski"
     assert empl.rate_per_hour == 100.0
 def test_employee_pay_salary_overtime(self):
     empl = Employee("Rafał", "Korzeniewski", 100.0)
     empl.register_time(10)
     assert empl.pay_salary() == 8 * 100 + 2 * 2 * 100
 def test_employee_pay_salary(self):
     empl = Employee("Rafał", "Korzeniewski", 100.0)
     assert empl.pay_salary() == 0
     empl.register_time(5)
     assert empl.pay_salary() == 500
     assert empl.pay_salary() == 0
Example #11
0
from company import Employee

# Create some employees and display them.
emp1 = Employee("Bill", 15000)		
emp2 = Employee("Ben", 20000)		
print(emp1.toString())
print(emp2.toString())