Beispiel #1
0
class TestEmployee(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        #this runs first, before everything
        print('setupClass')

    @classmethod
    def tearDownClass(cls):
        #this runs last, after everything
        print('teardownClass')

    def setUp(self):
        #this runs before every test
        print('setUp')
        self.emp_1 = Employee('Corey', 'Schafer', 50000)
        self.emp_2 = Employee('Sue', 'Smith', 60000)

    def tearDown(self):
        #this runs after every test
        print('tearDown\n')

    def test_email(self):
        print('test_email')
        self.assertEqual(self.emp_1.email, '*****@*****.**')
        self.assertEqual(self.emp_2.email, '*****@*****.**')

        self.emp_1.first = 'John'
        self.emp_2.first = 'Jane'

        self.assertEqual(self.emp_1.email, '*****@*****.**')
        self.assertEqual(self.emp_2.email, '*****@*****.**')

    def test_fullname(self):
        print('test_fullname')
        self.assertEqual(self.emp_1.fullname, 'Corey Schafer')
        self.assertEqual(self.emp_2.fullname, 'Sue Smith')

        self.emp_1.first = 'John'
        self.emp_2.first = 'Jane'

        self.assertEqual(self.emp_1.fullname, 'John Schafer')
        self.assertEqual(self.emp_2.fullname, 'Jane Smith')

    def test_apply_raise(self):
        print('test_apply_raise')
        self.emp_1.apply_raise()
        self.emp_2.apply_raise()

        self.assertEqual(self.emp_1.pay, 52500)
        self.assertEqual(self.emp_2.pay, 63000)

    '''def test_monthly_schedule(self):
def build_graph(filename):
    """ This method takes the text file and builds the graph """
    if not os.path.isfile(filename):
        # If the file does not exist, return nothing
        raise NonExistentFile("%s does not exist." % filename)

    # Create the graph file
    orgchart = OrganisationChart()
    # Open the file and loop through the data
    f = open(filename, 'r')
    # Read the column headers
    header = f.readline()

    file_data = []
    for line in f:
        # Split the line into rows
        line_data = line.split("|")
        # Take in the appropriate data, and remove trailing and leading spaces
        id = line_data[1].lstrip().rstrip()
        name = line_data[2].lstrip().rstrip()
        manager = line_data[3].lstrip().rstrip()
        emp = Employee(name, id, manager)
        orgchart.add_employee(emp)

    return orgchart
Beispiel #3
0
class EmployeeTestCase(unittest.TestCase):
    '''Test for the employee class'''

    def setUp(self):
        '''Create set of caracteristics for the employee'''
        self.my_employee = Employee('jay', 'gonzalez', 45000)

    def test_give_default_raise(self):
        '''test that the employee see the salary incremented in 5000'''
        self.my_employee.give_raise()
        self.assertEqual(self.my_employee.salary, 50000)

    def test_give_custom_raise(self):
        '''test that a custom quantity in give raise f(x) is added correctly to the salary'''
        self.my_employee.give_raise(10000)
        self.assertEqual(self.my_employee.salary, 55000)
Beispiel #4
0
 def setUp(self):  # this has to be capital U: setUp vs setup
     """
     create employees so I don't have do this each time
     """
     self.my_employee = Employee('Derel', 'Merel', 80000)
     self.salary = 80000
     self.name = 'Derel'
     self.last_name = 'Merel'
Beispiel #5
0
def addEmployee(session):
    person = addPerson(session)
    employeeDetails = _parseUserInput("Enter basic employee details in teh following format: \n role seniority location salary", 4)
    employeeDetails[0] = _setString(employeeDetails[0])
    employeeDetails[1] = _setString(employeeDetails[1])
    employeeDetails[2] = _setString(employeeDetails[2])
    employeeDetails[3] = _setString(employeeDetails[3])

    employee = Employee(role=employeeDetails[0],
                        seniority=employeeDetails[1],
                        location=employeeDetails[2],
                        salary=employeeDetails[3],
                        person=person)
    session.add(employee)
    session.commit()
Beispiel #6
0
from classes import Employee
import datetime

emp3 = Employee('Sarah', '*****@*****.**', 'backend', 48000)

Employee.set_period_bonus(6000)
print(emp3.impinfo())
emp3.increase_pay()
print(emp3.pay)

date = datetime.date(2021, 3, 20)
Employee.is_working_day(date)
Beispiel #7
0
 def __init__(self, *args, **kwargs):
     Employee.__init__(self, *args, **kwargs)
     self.skills = []
Beispiel #8
0
 def setUp(self):
     #this runs before every test
     print('setUp')
     self.emp_1 = Employee('Corey', 'Schafer', 50000)
     self.emp_2 = Employee('Sue', 'Smith', 60000)
Beispiel #9
0
from classes import Person, Employee

person = Person('Katy', 43)
person.age = 35
person.print_info()

employee = Employee('Nick', 30, 'Yandex')
employee.print_info()
employee.more_info()
print(employee)
from classes import Person, Employee

person = Person('Katy', 30)
person.age = 35
person.print_info()

employee = Employee('Nick', 30, 'Google')
employee.print_info()
employee.more_info()
print(employee)
Beispiel #11
0
 def test_get_employee(self):
     self.nombre = "Oriel"
     self.age = 23
     self.salary = 32000
     emp1 = Employee.get_employee(self)
     self.assertEqual(emp1, ["Oriel", 23, 32000])
Beispiel #12
0
 def test_pay_taxes(self):
     self.age = 48
     self.salary = 50000
     imp1 = Employee.pay_tax(self)
     self.assertEqual(imp1, "Paga impuestos")
from classes import Person, Employee

person2 = Person('Katy', 32)
person2.age = 40
person2.print_info()

employee = Employee('Nik', 22, 'Google')
employee.print_info()
employee.more_info()
print(employee)
from classes import Employee

emp2 = Employee("Hasan","*****@*****.**","FrontEnd",40000)

print(emp2.impinfo())

emp2.increase_pay()

print(emp2.pay)
print(emp2.__dict__)
from classes import Employee

test_emp1 = Employee('sadia', '*****@*****.**', 'BBA', 35000)
test_emp2 = Employee('dipa', '*****@*****.**', 'abal', 36000)
print(test_emp1)

print(int.__add__(1, 2))
print(str.__add__('hola ', 'buenas tardas'))

print(test_emp1 + test_emp2)
Beispiel #16
0
	def __init__(self, iq=150):
		Employee.__init__(self, "Poindexter")
		self.iq = iq
Beispiel #17
0
from package import *
from classes import Employee, Student
a()
b()
c()

e1 = Employee(101, "Rajat", 21, 10000, "pat")
e1.display()

e2 = Student(101, "Rajat", 21)
e2.display()
Beispiel #18
0
from classes import Employee

a = Employee("isxoqjon", 'iTeach')

print(a.company)
Beispiel #19
0
from classes import Person, Employee

person = Person('Katy', 30)
person.age = 35
person.print_info()

employee = Employee('Job', 25, 'Google')
employee.print_info()
employee.more_info()
employee.__str__()
print(employee)












Beispiel #20
0
from functions import *
from classes import Employee, Student

a()
b()
c()

e1 = Employee(101, "Payal", 22, 1000000, "CEO")
e1.display()

s1 = Student(11, "ranu", 12)
s1.display()
Beispiel #21
0
 def test_no_pay_taxes(self):
     self.age = 23
     self.salary = 31999
     imp2 = Employee.pay_tax(self)
     self.assertEqual(imp2, "No paga impuestos")
Beispiel #22
0
from classes import Person, Employee

person2 = Person('Katy', 32)
person2.age = 40
person2.print_info()

employee = Employee('Nik', 22)
employee.print_info()
employee.more_info()
Beispiel #23
0
 def setUp(self):
     '''Create set of caracteristics for the employee'''
     self.my_employee = Employee('jay', 'gonzalez', 45000)
Beispiel #24
0
# modules and packages
# modules - pieces of code split into logical sections. these python files can be imported and reused
# packages - a collection of modules

#Example:
from classes import Employee

chiya = Employee('chiya', 2000, 5)
print(f'Employee name: {chiya.name}')
print(f'Salary: {chiya.salary}')
print(f'time spent at work: {chiya.duration}')
print(chiya.time_spent())

#Package
#setup:
# create folder
# add __init__.py file
#add other py files in folder
Beispiel #25
0
def main():
    print("Creating 'Supervisor' object 'tyler'")
    tyler = Supervisor("Tyler Whitney", "09171987", "Computing Systems")
    tyler.printName()
    print("Is Manager? " + str(tyler.isManager()))
    print("Service: " + tyler.getService())

    print('')

    print("Creating 'Employee' object 'one'")
    one = Employee("John Doe", 9, 12, 1982)
    one.printName()
    print("Service Length: " + str(one.getService()))

    print('')

    print("Added 'one' as employee under 'tyler'")
    tyler.addEmployee(one)
    print("-- Emplyoees under 'tyler' object")
    tyler.printEmployeeNames()
    print(" ----- ")
    print("Is 'tyler' Manager? " + str(tyler.isManager()))

    print('')

    print("Creating 'Supervisor' object 'two'")
    two = Supervisor("Eric Twofer", "08231999", "Marketing and Communications")
    two.printName()
    print("Changing name of 'two' to a different name and department")
    two.setName("Eric J Twofer", "MarCom")
    two.printName()
    print("Service Length: " + str(two.getService()))

    print('')

    print("Setting contact info for object 'tyler'")
    tyler.setContactInfo("5642449", "5552400", "*****@*****.**")
    info = tyler.getContactInfo()
    print("-- Printing Contact Info from 'getContactInfo' method --")
    print("Phone: " + info['phone'])
    print("Fax: " + info['fax'])
    print("Email: " + info['email'])
    print(" ----- ")
    print(
        "-- Printing Contact Info from individual 'getPhone', 'getFax', 'getEmail' methods --"
    )
    print("Phone: " + tyler.getPhone())
    print("Fax: " + tyler.getFax())
    print("Email: " + tyler.getEmail())
    print(" ----- ")

    print('')

    print("Adding 'two' object as employee under 'tyler'")
    tyler.addEmployee(two)
    print("-- Employees under 'tyler' object -- ")
    tyler.printEmployeeNames()
    print(" ----- ")
    print(
        "Removing 'two' object from employee under 'tyler', ('Eric J Twofer')")
    tyler.removeEmployee("Eric J Twofer")
    print("-- Employees under 'tyler' object --")
    tyler.printEmployeeNames()
    print(" ----- ")
from classes import Person, Employee

person = Person('Katy', 30)
person.age = 35
person.print_info()

employee = Employee('Nick', 30)
employee.print_info()
employee.more_info()