Пример #1
0
    def setUp(self):
        self.employee_1 = employee.Employee('Derrick', 'kimathi')
        self.employee_2 = employee.Employee('austin', 'mutuma')

        # test object creation
        self.assertIsInstance(self.employee_1, employee.Employee)
        self.assertIsInstance(self.employee_2, employee.Employee)
def _test_update_employee():
    bday = datetime.date(1995, 10, 14)
    new_emp = employee.Employee("A123", "m", 999, "normal", 77, bday, 21)
    new_emp2 = employee.Employee("X999", "m", 2, "normal", 77, bday, 21)
    data = _get_test_object()
    data.update_employee(new_emp)
    data.update_employee(new_emp2)
Пример #3
0
 def setUp(self) -> None:
     """
      run the code inside this function before every single test
      In this case every time we create objects that use for tests
     """
     self.emp_1 = employee.Employee('Oleksii', 'Sheiko', 50000)
     self.emp_2 = employee.Employee('Vovan', 'Kovalenko', 70000)
Пример #4
0
def main():

    worker0 = employee.Employee('Сьюзан Мейерс', '47899', 'Бухгалтерия',
                                'Вице-президент')
    worker1 = employee.Employee('МаркДжоунс', '39119', 'ИТ', 'Программист')
    worker2 = employee.Employee('Джой Роджерс', '81774', 'Производственный',
                                'Инженер')

    print('[Имя         ][ИД   ][Отдел    ][Должность   ]')
    print(worker0)
    print(worker1)
    print(worker2)
Пример #5
0
def main():
    employees = []
    employee1 = employee.Employee('Susan Meyers','47899','Accounting','Vice President')
    employee2 = employee.Employee('Mark Jones', '39119','IT','Programmer')
    employee3 = employee.Employee('Joy Rogers', '81774','Manufacturing','Engineer')
    employees = [employee1, employee2, employee3]
    print('-------------------------------------------------------------------------------------')
    print('                           Employees                                                 ')
    print('-------------------------------------------------------------------------------------')
    for x in employees:
        print(x)
    print('-------------------------------------------------------------------------------------')
Пример #6
0
def main():

    employee1 = employee.Employee("Susan Meyers", '47899' , 'Accounting', 'Vice President')
    employee2 = employee.Employee("Mark Jone", '39119' , 'IT', 'Programmer')
    employee3 = employee.Employee("Joy Rogers ", '81774' , 'Manufacturing', 'Engineer')

    print()
    print('-----------------------------------------------------------------------------------')
    print('{:<20}'.format('Name') + '{:<20}'.format('Id Number') + '{:<20}'.format('Department') +'{:<20}'.format('Title'))
    print('-----------------------------------------------------------------------------------')
    #print(employee1, '\n', employee2, '\n', employee3)
    print(employee1)
    print(employee2)
    print(employee3)  
Пример #7
0
 def add_emp(self):
     name = input('name: ')
     phone = input('phone: ')
     home = input('home: ')
     address = input('address: ')
     emp = employee.Employee(name, phone, home, address)
     self.emp_list.append(emp)
Пример #8
0
 def setUp(self):
     self.first = 'caiyun'
     self.last = 'zhao'
     self.salary = 1000
     self.employee_tester = employee.Employee(self.first, self.last,
                                              self.salary)
     self.add = 3000
def main():
    '''
    The main program
    '''
    # variables
    employees = ([ None ] * N_EMPLOYEES)            # list of employees
    options = (list(range(1, N_EMPLOYEES)) + [ 0 ]) # list of options
    callbacks = (( employee_menu, ) * N_EMPLOYEES)  # list of callback
                                                    #   functions of employees
    #

    # stringify the options
    slew.stringify_in(N_EMPLOYEES, options)
    options = tuple(options)

    # populate the list with employees
    for k in range(0, N_EMPLOYEES):
        employees[k] = employee.Employee()
        employees[k].set_name('#' + str(k + 1))
    # end for k in range(0, N_EMPLOYEES)

    # employees is not finalized because it may change
    # if the title of the employee changes

    # main menu
    slew.option_menu_apply(N_EMPLOYEES,\
        slew.create_legend('Employees'), ':\n',\
        options, get_employee_titled_name,\
        'Choose an employee to manage. [default STOP]',\
        callbacks, employees, '\n> ', 'Invalid employee chosen.'
    )

    # finish
    print('Done.')
Пример #10
0
def load_file(att=False, not_att=False):
    data = []
    with open('./data/data.csv', 'r') as file:
        for idx, line in enumerate(file):
            tmp = line.split(',')
            if idx == 0:
                continue
            if att:
                if tmp[1] == 'Yes':
                    data.append(employee.Employee(line))
            elif not_att:
                if tmp[1] == 'No':
                    data.append(employee.Employee(line))
            else:
                data.append(employee.Employee(line))
    return data
Пример #11
0
def addEntry(dictionary):
    emp = e.Employee()
    emp.set_name()
    emp.set_id()
    emp.set_dept()
    emp.set_title()
    dictionary.update({emp.get_id(): emp})
Пример #12
0
def main():
    employee1 = employee.Employee(name="Mary Jane",
                                  id_number="1234",
                                  department="Nursing",
                                  job_title="Nurse")

    print(employee1)
Пример #13
0
def main():
    """Get the users Name as a string"""
    name = input("Please enter in your name: ")

    """Ask the user to enter a number if they are a Director, Manager or Staff."""
    """This will check and make sure the user only enters in 1,2, 
    or 3 and a number greater than zero"""
    while True:
        try:
            designation_number = int(input("Please enter in \n1 for Director "
                                           "\n2 for Manager \n3 for Staff\n"))
            if 0 < designation_number <= 3:
                break
            print("Invalid number entered.")
        except Exception as e:
            print(e)
    """Gets the user salary and makes sure is a number and greater than 0"""
    while True:
        try:
            salary = float(input("Please enter in your salary: "))
            if salary <= 0:
                print("Your salary must be at least 1 dollar. Please enter a number greater than zero.")
            else:
                break
        except ValueError:
            print("Oops! That was not a valid number. Try again...")

    """Create Employee"""
    employee1 = employee.Employee()
    employee1.set_name(name)
    employee1.set_designation(designation_number)
    employee1.set_salary(salary)
    print(employee1)
Пример #14
0
 def test_m4_Org_add_employee(self):
     """
     Test Org Class and Add Employee Function
     :return:
     """
     self.test_org = m4.Org()
     self.employee_type_e = employee.Employee('name_new',
                                              leader=None,
                                              salary=0)
     self.employee_type_m = employee.Manager('name_new',
                                             leader=None,
                                             salary=0)
     """
     Test if added to array correctly.
     """
     self.assertIsInstance(self.test_org.add_employee(self.employee_type_e),
                           list)
     self.assertIsInstance(self.test_org.add_employee(self.employee_type_m),
                           list)
     """
     Test to see if add employee only accepts type Employee or Manager
     """
     self.assertFalse(self.test_org.add_employee(None))
     self.assertFalse(self.test_org.add_employee(list()))
     self.assertFalse(self.test_org.add_employee(tuple()))
     self.assertFalse(self.test_org.add_employee(dict()))
     self.assertFalse(self.test_org.add_employee(str()))
Пример #15
0
def make_list():

    # Creating an empty list.

    person_list = []

    # Adding three Employee objects to the list.
    count = 0
    count += 1
    for count in range(1, 4):
        name = input('Enter employee name: ')
        idnum = input('Enter employee ID: ')
        dept = input('Enter department: ')
        title = input('Enter position: ')
        print()


# Creating a new Employee object and ssigning it to the person variable.

    person = employee.Employee(name, idnum, dept, title)

    # Adding the object to the list.

    person_list.append(person)
    return person_list
Пример #16
0
def main():
    # Create and initialize objects using 'Employee()' class
    employee1 = employee.Employee()
    employee2 = employee.Employee()
    employee3 = employee.Employee()

    # assign values to variables that will be passed to 'employee1'
    # as well as name of the business (to be used in output function)
    business_name = str(input("What's the name of the business? "))
    employee_name = str(input("What's the 1st employee's name? "))
    ID_number = str(input("What's the 1st employee's ID number? "))
    employee_department = str(input("What's the 1st employee's department? "))
    employee_jobTitle = str(input("What's the 1st employee's job title? "))

    # pass values of variables collected to object employee1 via parameters of input methods
    employee1.set_name(employee_name)
    employee1.set_IDnumber(ID_number)
    employee1.set_department(employee_department)
    employee1.set_jobTitle(employee_jobTitle)

    # assign values to variables that will be passed to 'employee2' object
    employee_name = str(input("What's the 2nd employee's name? "))
    ID_number = str(input("What's the 2nd employee's ID number? "))
    employee_department = str(input("What's the 2nd employee's department? "))
    employee_jobTitle = str(input("What's the 2nd employee's job title? "))

    # pass values of variables collected to object employee1 via parameters of input methods
    employee2.set_name(employee_name)
    employee2.set_IDnumber(ID_number)
    employee2.set_department(employee_department)
    employee2.set_jobTitle(employee_jobTitle)

    # assign values to variables that will be passed to 'employee2' object
    employee_name = str(input("What's the 3rd employee's name? "))
    ID_number = str(input("What's the 3rd employee's ID number? "))
    employee_department = str(input("What's the 3rd employee's department? "))
    employee_jobTitle = str(input("What's the 3rd employee's job title? "))

    # pass values of variables collected to object employee1 via parameters of input methods
    employee3.set_name(employee_name)
    employee3.set_IDnumber(ID_number)
    employee3.set_department(employee_department)
    employee3.set_jobTitle(employee_jobTitle)

    # Call 'displayEmployees(parameters)' function and pass object information through parameters
    displayEmployees(employee1, employee2, employee3, business_name)
Пример #17
0
def test_add_new_employee():
    emp = employee.Employee('Jan', 'Kowalski', 5000, 1970)
    assert emp.add_employee() == [{
        'name': 'Jan',
        'last_name': 'Kowalski',
        'salary': 5000,
        'birth_year': 1970
    }]
def add_new_employee(employee_dict):
    print('Add new employee:')
    name = input('Enter employee name: ').title()
    id_number = validate.id_number(input('Enter 5-digit ID number: '))
    department = input('Enter department: ').title()
    job_title = input('Enter job title: ').title()

    employee_dict[id_number] = employee.Employee(name, id_number, department,
                                                 job_title)
def lambda_handler(event, context):
    """Lambda Function to process patch request for single user. User ID shall be passed from path parameter. fields to
    be processed will be passed in from body field. All other three fields are required: login, name, salary.

   Args:
    event: dict, required
        API Gateway Lambda Proxy Input Format

    context: object, required
        Lambda Context runtime methods and attributes

    Returns:
        Json response contains the following fields:
        1. statusCode: 200 (Valid Response); 400 (Invalid Request);
        2. body: Json data contains return standard message.
    """

    # todo due to time constrain, assume id is valid
    # todo db locking check is not enabled, assume the each time is only one operation taken place

    employee_id = event["pathParameters"]["id"]

    check_user_id_exist = retrieve_user_record_by_id(employee_id)

    if check_user_id_exist["statusCode"] == 400:
        return http_responses.http_standard_return(
            False, failed_msg=USER_DOES_NOT_EXIST_CANNOT_PATCH)

    if not event["body"]:
        return http_responses.http_standard_return(
            False, failed_msg=INVALID_BODY_INPUT)

    if isinstance(event["body"], str):
        try:
            event["body"] = json.loads(event["body"])
        except Exception as e:
            return http_responses.http_standard_return(
                False, failed_msg=INVALID_BODY_INPUT)

    if not user_cr_validation(event["body"]):
        return http_responses.http_standard_return(
            False, failed_msg=INVALID_BODY_INPUT)

    login = event["body"]["login"]
    name = event["body"]["name"]
    salary = event["body"]["salary"]

    new_employee = employee.Employee(employee_id, login, name, salary)

    upload_status = database_helper.create_employee(new_employee)

    if upload_status == DB_FAILED_OPERATION:
        return http_responses.http_standard_return(
            False, failed_msg=INVALID_BODY_INPUT)

    return http_responses.http_standard_return(
        True, success_msg=VALID_CR_DB_OPERATION)
Пример #20
0
    def _do_who(self, who):
        """For internal use only

        I really mean it.
        """
        try:
            e = employee.Employee(who)
        except employee.EmployeeDoesNotExistError as e:
            print (e)
        else:
            print('{0}\n    {1}'.format(e, e.title))
Пример #21
0
def add(employees):
    id = int(input("Enter ID number: "))
    name = input("Enter a name: ")
    dep = input("Enter the department: ")
    job = input("Enter the job title: ")
    entry = employee.Employee(id, name, dep, job)
    if id not in employees:
        employees[id] = entry
        print("Added")
    else:
        print("That ig already exists")
Пример #22
0
def change(employees):
    id = int(input("Enter ID number: "))
    if id in employees:
        name = input("Enter a name: ")
        dep = input("Enter the department: ")
        job = input("Enter the job title: ")
        entry = employee.Employee(id, name, dep, job)
        employees[id] = entry
        print("Updated")
    else:
        print("ID not found")
Пример #23
0
def make_list():

# Creating an empty list.

    person_list = []

# Adding three Employee objects to the list.
    
# First employee:

    name1 = input('Enter employee name: ')
    idnum1 = input('Enter employee ID: ')
    dept1 = input('Enter department: ')
    title1 = input('Enter position: ')
    print()
    person1 = employee.Employee(name1, idnum1, dept1, title1)

# Second employee:

    name2 = input('Enter employee name: ')
    idnum2 = input('Enter employee ID: ')
    dept2 = input('Enter department: ')
    title2 = input('Enter position: ')
    print() 
    person2 = employee.Employee(name2, idnum2, dept2, title2)

# Third employee:

    name3 = input('Enter employee name: ')
    idnum3 = input('Enter employee ID: ')
    dept3 = input('Enter department: ')
    title3 = input('Enter position: ')
    print()
    person3 = employee.Employee(name3, idnum3, dept3, title3)
    
# Adding the object to the list.

    person_list.append(person1)
    person_list.append(person2)
    person_list.append(person3)
    return person_list
def change(employees):
    id_number = input("Enter employee ID: ")
    if id_number in employees.keys():
        name = input("Enter employee's new name: ")
        department = input("Enter employee's new department: ")
        job_title = input("Enter employee's new job title: ")
        emp = employee.Employee(name, id_number, department, job_title)
        employees[id_number] = emp
        print("\nID: " + id_number + " - " + name + " has been updated.")
    else:
        print("\nAn employee with ID:", id_number, "does not exist.")
    return employees
def add(employees):
    id_number = input("Enter employee ID: ")
    if id_number not in employees.keys():
        name = input("Enter employee's name: ")
        department = input("Enter employee's department: ")
        job_title = input("Enter employee's job title: ")
        emp = employee.Employee(name, id_number, department, job_title)
        employees[id_number] = emp
        print("\nID: " + id_number + " - " + name + " has been added.")
    else:
        print("\nAn employee with ID:", id_number, "already exists.")
    return employees
Пример #26
0
def change(employees):

    id = raw_input("Enter the employee's ID_number to change information: ")

    if id in employees:
        name = raw_input("Enter the name of the employee: ")
        department = raw_input("Enter the department for which the employee works for: ")
        job_title = raw_input("Enter the employee's Job Title: ")

        entry = employee.Employee(name, id, department, job_title)

    else:
        print "Employee's ID_number not Found!"
Пример #27
0
def init():
    with open("employee_dictionary.csv", "r") as file_object:
        next(file_object)
        lines = [line.strip().split(",") for line in file_object]

        for row in lines:

            employee1 = employee.Employee(name=row[1],
                                          id_number=row[0],
                                          department=row[2],
                                          job_title=row[3])
            # print(employee1)
            employee_look_up[employee1.get_id_number()] = employee1
Пример #28
0
def change(myemp):
    emp_ID = input("Enter an employee ID: ")
    if emp_ID in myemp:
        name = input("Enter the new name: ")
        dep = input("Enter the new department: ")
        jobtitle = input("Enter the new job title: ")

        changed = employee.Employee(name, emp_ID, dep, jobtitle)

        myemp[emp_ID] = changed
        print("Information updated.")
    else:
        print("That employee is not found.")
Пример #29
0
def add(myemp):
    name = input("Enter name of the employee: ")
    emp_ID = input("Enter ID Number: ")
    dep = input("Enter department: ")
    jobtitle = input("Enter the job title: ")

    new_employee = employee.Employee(name, emp_ID, dep, jobtitle)

    if emp_ID not in myemp:
        myemp[emp_ID] = new_employee
        print("New employee has been added.")
    else:
        print("That employee already exists.")
Пример #30
0
def main():

    emp_name = ''
    emp_id = 0
    emp_dept = ''
    emp_title = ''
    employee_dict = {}
    emp_dict = {}
    employee_list = []

    empl = employee.Employee(emp_id, emp_name, emp_dept, emp_title)

    emp_dict = {
        'emp_id': 47899,
        'emp_name': 'Susan_Meyers',
        'emp_dept': 'Accounting',
        'emp_title': 'Vice President'
    }
    employee_list.append(emp_dict)
    emp_dict = {
        'emp_id': 39119,
        'emp_name': 'Mark Jones',
        'emp_dept': 'IT',
        'emp_title': 'Programmer'
    }
    employee_list.append(emp_dict)
    emp_dict = {
        'emp_id': 81774,
        'emp_name': 'Joy Rogers',
        'emp_dept': 'Manufacturing',
        'emp_title': 'Engineer'
    }
    employee_list.append(emp_dict)

    for i in range(len(employee_list)):
        employee_dict = employee_list[i]
        emp_id = employee_dict['emp_id']
        emp_name = employee_dict['emp_name']
        emp_dept = employee_dict['emp_dept']
        emp_title = employee_dict['emp_title']

        empl.set_id_number(emp_id)
        empl.set_name(emp_name)
        empl.set_department(emp_dept)
        empl.set_job_title(emp_title)

        print('Employee ID =', empl.get_id_number(emp_id))
        print('Employee Name=', empl.get_name(emp_name))
        print('Employee Department =', empl.get_department(emp_dept))
        print('Employee Title=', empl.get_job_title(emp_title))
        print('\n')