Example #1
0
def getHighestSalary(l):
	"""Returns the employee in l with the highest salary"""
	highest = Employee("Test", "Test", "test", 0)
	for e in l:
		if e.getSalary() > highest.getSalary():
			highest = e
	return e
Example #2
0
	def __init__(self, firstname, lastname, socialSecurity, salary, 
		               title, bonus):
		"""
		Sets firstname, lastname, SSN, salary, title and bonus.
		"""
		Employee.__init__(self, firstname, lastname, socialSecurity, salary)
		self.title = title
		self.bonus = bonus
class TestEmployee(unittest.TestCase):
    def setUp(self):
        self.employee = Employee('Joe', 'Blow', 100000)
    
    def test_give_default_raise(self):
        self.employee.give_raise()
        self.assertEqual(self.employee.salary, 105000)
    
    def test_give_custom_raise(self):
        self.employee.give_raise(17000)
        self.assertEqual(self.employee.salary, 117000)
class EmployeeTestCase(unittest.TestCase):
    def setUp(self):
        self.test_emp = Employee("Dan", "Gaylord", 60000)
        self.amount = 10000

    def test_give_default_raise(self):
        self.test_emp.give_raise()
        self.assertEqual(self.test_emp.salary, 65000)

    def test_give_custom_raise(self):
        self.test_emp.give_raise(self.amount)
        self.assertEqual(self.test_emp.salary, 70000)
Example #5
0
class TestEmployee(unittest.TestCase):

	def setUp(self):
		"""Create default employee instance."""
		self.employee = Employee('zheng hong', 'tan', 7000)

	def test_give_default_raise(self):
		self.employee.give_raise()
		self.assertEqual(12000, self.employee.annual_salary)

	def test_give_custom_raise(self):
		self.employee.give_raise(400)
		self.assertEqual(7400, self.employee.annual_salary)
Example #6
0
    def init_table(self):
        self.cursor = self.db.cursor()

        columns = Employee().to_dict()
        del columns['id']

        request = 'CREATE TABLE IF NOT EXISTS employees '
        request += "(id INTEGER PRIMARY KEY UNIQUE"
        for column, value in columns.items():
            request += ', ' + column + ' ' + \
                           sql_types[type(value).__name__]
        request += ")"
        
        self.cursor.execute(request)
        self.db.commit()
Example #7
0
 def __init__(self, title, annualBonus):
      """
      Sets the employee default values, title, and annual bonus. It also
      checks to see if values are valid and sets them to default values if they
      aren't.
      """
      Employee.__init__(self, "Generic First Name", "Generic Last Name", 123456789, 60000)
      if type(title) == str:
          self.title = title
      else:
          self.title = "Head Manager"
      if type(annualBonus) == int or type(annualBonus) == float:
          self.annualBonus = annualBonus
      else:
          self.annualBonus = 5000.0
Example #8
0
class TestEmployeeSalary(unittest.TestCase):
	"""Tests for the class employee.py"""
	
	def setUp(self):
		"""Create instance of class"""
		self.my_employee = Employee('Joel', 'Kitchen', 10000)
		
	def test_give_default_raise(self):
		"""Tests employee gets default raise"""
		self.my_employee.give_raise()
		self.assertEqual(15000, self.my_employee.annual_salary)
		
	def test_give_custom_raise(self,raise_amount=10000):
		"""Tests employee gets custom raise"""	
		self.my_employee.give_raise(raise_amount)
		self.assertEqual(20000, self.my_employee.annual_salary)
Example #9
0
    def load_employees(self, filters = None, #sorting = 'id',
                       first_index = 0, last_index = 10000):

        limit = last_index - first_index + 1
        offset = first_index
        
        columns = Employee().to_dict().keys()
        request = 'SELECT '
        for column in columns:
            request += column + ', '
        request = request[0:-2] + ' FROM employees '
        if filters != None and len(filters) != 0:
            request = request + 'WHERE '
            for key in filters.keys():
                request += key + ' = ' + self.f + ' AND '
            request = request[0:-5]
        #request += ' ORDER BY ' + sorting
        #request += ' LIMIT ' + str(limit)
        #request += ' OFFSET ' + str(offset)


        try:
            if filters != None and len(filters) != 0:
                self.cursor.execute(request, filters.values())
            else:
                self.cursor.execute(request)
            rows = self.cursor.fetchall()
        except Exception as e:
            print traceback.format_exc()
            print e
            rows = []

        employees = []
        for row in rows:
            values_dict = {}
            for i in xrange(len(columns)):
                values_dict[columns[i]] = row[i]
            employee = Employee()
            employee.set_values(values_dict)
            employees.append(employee)
        return employees
	def getCrew(self, date, shift, satisfactory):
		employees = []
		list = Constrain.query(Constrain.constrainDate == date, Constrain.ShiftType == shift, Constrain.constrainKind == satisfactory).fetch()		
		if list:
			for l in list:
				shiftHead = Employee.getEmployeeByUserName(l.employeeUN)
				if shiftHead:
					employees.append(shiftHead.userName)		
			
			return employees
		else:
			return None
class TestEmployee(unittest.TestCase):
    """Test for the class Employee."""

    def setUp(self):
        """
        Create an employee for use in all test methods
        """
        self.employee = Employee("Test", "Testerson", 30000)

    def test_give_default_raise(self):
        """Test give_raise method with default value."""
        current_salary = self.employee.salary
        self.employee.give_raise()

        self.assertEqual(current_salary + 5000, self.employee.salary)

    def test_give_custom_raise(self):
        """Test give_raise method with custom value."""
        custom_raise = 10000
        current_salary = self.employee.salary
        self.employee.give_raise(custom_raise)

        self.assertEqual(current_salary + custom_raise, self.employee.salary)
class Employee_test(unittest.TestCase):
    def setUp(self):
        self.employee = Employee()

    def set_values_tests(self):
        values = {'id' : 10,
                  'name' : 'John',
                  'age' : 30}
        self.employee.set_values(values)
        assert self.employee.id == values['id']
        assert self.employee.name == values['name']
        assert self.employee.age == values['age']
        
        values2 = self.employee.to_dict()
        for key in values.keys():
            assert values[key] == values2[key]

    def add_working_seconds_test(self):
        hours = 5
        seconds = hours * 60 * 60
        self.employee.add_working_seconds(seconds)
        self.employee.add_working_seconds(seconds)
        assert self.employee.get_working_hours(utils.current_month()) == hours * 2
        assert self.employee.get_working_hours('01 1999') == 0
 def setUp(self):
     """
     Create an employee for use in all test methods
     """
     self.employee = Employee("Test", "Testerson", 30000)
Example #14
0
                'last': emp.last,
                'pay': pay
            })


def remove_emp(emp):
    with conn:
        c.execute(
            "DELETE from employees WHERE first = :first AND last = :last", {
                'first': emp.first,
                'last': emp.last
            })


#c.execute("""CREATE TABLE employees(first text,last text,pay integer)""")
emp_1 = Employee('John', 'Doe', 80000)
emp_2 = Employee('Jane', 'Doe', 90000)

#c.execute("insert into employees values('shivam','puri',100000)")

#c.execute("insert into employees values(?,?,?)",(emp_1.first,emp_1.last,emp_1.pay))       #one way
#conn.commit()

#c.execute("INSERT INTO employees VALUES (:first, :last, :pay)", {'first': emp_2.first, 'last': emp_2.last, 'pay': emp_2.pay}) #another way
#conn.commit()

#c.execute("select * from employees where last ='puri'")
#c.fetchmany(5)
#print c.fetchall()

#c.execute("select * from employees where last=:ls")
Example #15
0
    def setUp(self):

        self.snape = Employee('severus', 'snape', 100000)
class TestEmployee(unittest.TestCase):

    # one is before anything
    @classmethod
    def setUpClass(cls):
        print('setupClass')

    # one is after everything
    @classmethod
    def tearDownClass(cls):
        print('teardownClass')

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

    # after each test
    def tearDown(self):
        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):
        with patch('employee.requests.get') as mocked_get:
            mocked_get.return_value.ok = True
            mocked_get.return_value.text = 'Success'

            schedule = self.emp_1.monthly_schedule('May')
            mocked_get.assert_called_with('http://company.com/Schafer/May')
            self.assertEqual(schedule, 'Success')

            mocked_get.return_value.ok = False

            schedule = self.emp_2.monthly_schedule('June')
            mocked_get.assert_called_with('http://company.com/Smith/June')
            self.assertEqual(schedule, 'Bad Response!')
Example #17
0
    with conn:
        c.execute(
            """UPDATE employees SET pay = :pay WHERE first = :first AND last = :last""",
            {"first": emp.first, "last": emp.last, "pay": pay},
        )


def remove_emp(emp):
    with conn:
        c.execute(
            "DELETE FROM employees WHERE first = :first AND last = :last",
            {"first": emp.first, "last": emp.last},
        )


emp_1 = Employee("John", "Doe", 80000)
emp_2 = Employee("Jane", "Doe", 90000)

####  Vulnerable of SQL injection
# c.execute(
#     f'INSERT INTO employees VALUES ("{emp_1.first}", "{emp_1.last}", {emp_1.pay})'
# )

# c.execute(
#     "INSERT INTO employees VALUES (?, ?, ?)", (emp_1.first, emp_1.last, emp_1.pay)
# )

# c.execute(
#     "INSERT INTO employees VALUES (:first, :last, :pay)",
#     {"first": emp_2.first, "last": emp_2.last, "pay": emp_2.pay},
# )
Example #18
0
	def setUp(self):
		"""Create instance of class"""
		self.my_employee = Employee('Joel', 'Kitchen', 10000)
 def setUp(self):
     print('setup')
     self.levin = Employee('levin', 'batallones', 2000000)
     self.martin = Employee('martin', 'briceno', 1999999)
     self.cristina = Employee('cristina', 'nguyen', 100000)
Example #20
0
 def setUp(self):
     self.emp_1 = Employee('Corey', 'Schafer', 50000)
     self.emp_2 = Employee('Julio', 'Cezar', 100000)
     print("SetUp")
Example #21
0
class TestEmployee(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        print("setupclass\n")

    @classmethod
    def tearDownClass(cls):
        print('terDownClass')

    def setUp(self):
        self.emp_1 = Employee('Corey', 'Schafer', 50000)
        self.emp_2 = Employee('Julio', 'Cezar', 100000)
        print("SetUp")

    def tearDown(self):
        print("SetDown")

    def test_email(self):

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

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

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

    def test_fullname(self):
        self.assertEqual(self.emp_1.fullname, 'Corey Schafer')
        self.assertEqual(self.emp_2.fullname, 'Julio Cezar')

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

        self.assertEqual(self.emp_1.fullname, 'John Schafer')
        self.assertEqual(self.emp_2.fullname, 'Julio Jane')
        print("test_fullname")

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

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

        print("test_apply_raise")

    def test_monthly_schedule_true(self):
        with patch('employee.requests.get') as mocked_get:
            mocked_get.return_value.ok = True
            mocked_get.return_value.text = "You answer was sent with success"

            schedule = self.emp_1.monthly_schedule('May')
            mocked_get.assert_called_with('htpp://company.com/Schafer/May')
            self.assertEqual(schedule, 'You answer was sent with success')

    def test_monthly_schedule_false(self):
        with patch('employee.requests.get') as mocked_get:
            mocked_get.return_value.ok = False

            schedule = self.emp_2.monthly_schedule('June')
            mocked_get.assert_called_with('htpp://company.com/Cezar/June')
            self.assertEqual(schedule, 'Bad Response!')
Example #22
0
def test_give_default_raise():
    """Test that a default raise works correctly."""
    maria = Employee("Maria", "Hernandez", 5000)
    maria.give_raise()
    assert maria.salary == 10000
import csv
import sys
import Pyro4
import Pyro4.util
from  employee import Employee

sys.excepthook = Pyro4.util.excepthook
library = Pyro4.Proxy("PYRONAME:example.library")
employee = Employee()

f = open('./tasks.txt', 'r')
try:
	reader = csv.reader(f)
	for row in reader:
		print(row)
		if(row[0] == 'a'):
			employee.add_book(row, library) #add book

		elif(row[0] == 'sy'):
			employee.select_year(row[1], row[2], library) #select book by year 

		elif(row[0] == 'd'):
			employee.display(library) #display all the book

		elif(row[0] == 'si'):
			employee.select_ISBN(row[1],library) #select book by ISBN

		elif(row[0] == 'ol'):
			employee.on_loan(row[1],library) #set book on loan by ISBN

		elif(row[0] == 'nol'):
Example #24
0
def test_give_custom_raise():
    """Test that a custom raise works correctly."""
    joe = Employee("Joe", "Mama", 5000)
    joe.give_raise(10000)
    assert joe.salary == 15000
Example #25
0
        c.execute("""UPDATE employees SET pay = :pay
                  WHERE first = :first AND last = :last""",
                  {'first': emp.first,
                   'last': emp.last,
                   'pay': emp.pay})


def remove_emp(emp):
    with conn:
        c.execute(
            'DELETE FROM employees WHERE first = :first AND last = :last',
            {'first': emp.first,
             'last': emp.last})


emp_1 = Employee('John', 'Doe', 80000)
emp_2 = Employee('Kim', 'Doe', 50000)

insert_emp(emp_1)
insert_emp(emp_2)

emps = get_emps_by_name('Doe')
print(emps)

print("Updating emp_2's pay")
print("Current pay:", emp_2.pay)
update_pay(emp_2, 55555)
print("Pay after update:", emp_2.pay)
remove_emp(emp_1)

emps = get_emps_by_name('Doe')
Example #26
0
import sqlite3
from employee import Employee

conn = sqlite3.connect("employee.db")

c = conn.cursor()      #..............?

#c.execute("""CREATE TABLE employees(
#             first text,
#             last text,
#             pay integer
#             )""")

emp1 = Employee("john","Doe",80000)
emp2 = Employee("Jane","Doe",90000)
print(emp1.first)
print(emp1.last)
print(emp1.pay)
#c.execute("INSERT INTO employees VALUES('{}','{}',{})".format(emp1.first,emp1.last,emp1.pay))
c.execute("INSERT INTO employees VALUES(?,?,?)",(emp1.first,emp1.last,emp1.pay))
conn.commit()

c.execute("INSERT INTO employees VALUES(:first,:last,:pay)",{'first':emp2.first,'last':emp2.last,'pay':emp2.pay})
conn.commit()

#c.execute("INSERT INTO employees VALUES('balaji','sai kumar',50000)")
c.execute("SELECT * FROM employees WHERE last=?",("sai kumar",))
print(c.fetchone())

c.execute("SELECT * FROM employees WHERE last=:last",{"last":"Doe"})
print(c.fetchall())
"""
Test File. Testing all 3 phases of the program in different parts. I've also
imported each file and the relevant classes. 
"""

from employee import Employee
from manager import Manager

# Phase I testing
employee = Employee("Banana", "Thompson", 645348788, 1234123)
print(employee)
employee.giveRaise(0.1)
print(employee)

# Phase II testing
manager = Manager("Super Manager", 4500)
manager.giveRaise(0.3)
print(manager)
print("\n")

# Phase III testing
employee1 = Employee("Mexico", "Ferrari", "123Hey", 1234123)
employee2 = Employee("Max", "Power", 123098222, "meow")
manager1 = Manager("Mega Manager", 7000)
manager2 = Manager("Meh Manager", 2000)

employeeList = [employee1, employee2, manager1, manager2]

for employee in employeeList:
    print(employee)
Example #28
0
 def setUp(self):
     """Creates employee object for testing"""
     self.employee = Employee('Jose', 'Rivera', 23000)
 def __init__(self, name, salary):
     Employee.__init__(self, name, salary)
 def setUp(self):
     """Make an employee to use in tests."""
     self.eric = Employee('eric', 'metthes', 65000)
    def test_email(self):
        emp_1 = Employee('Corey', 'Schafer', 50000)
        emp_2 = Employee('Sue', 'Smith', 60000)

        self.assertEqual(emp_1.email, '*****@*****.**')
        self.assertEqual(emp_2.email, '*****@*****.**')
 def setUp(
     self
 ):  #Python doesn't usually camel case fucntion names but this is carried over from some legacy code.
     self.emp_1 = Employee('Corey', 'Schafer', 50000)
     self.emp_2 = Employee('Sue', 'Smith', 60000)
Example #33
0
 def setUp(self):
     print('setUp')
     # need to be instance attributes!
     self.emp_1 = Employee('Corey', 'Schafer', 50000)
     self.emp_2 = Employee('Sue', 'Smith', 60000)
Example #34
0
 def setUp(self):
     self.myEmployee = Employee('Vincent', 'Hu', 50000)
Example #35
0
 def setUp(self):
     print('\nsetUp')
     self.emp_1 = Employee('Corey', 'Schafer', 50000)
     self.emp_2 = Employee('Sue', 'Smith', 60000)
Example #36
0
 def setUp(self):
     print('setUp')
     self.emp_1 = Employee('Brock', 'Lesnar', 50000)
     self.emp_2 = Employee('John', 'Cena', 60000)
Example #37
0
""" Tests the Employee and Manager classes """
""" Imports Employee and Manager """
from employee import Employee
from manager import Manager

if __name__ == "__main__":
    """ Defines Employees and Managers """
    e1 = Employee("Jim", "Wellington III", "123-45-6789", 10000)
    e2 = Employee("Bob", "Connogherty", "132-42-5343", 25000)
    e3 = Employee("William", "Williamson", "098-76-5432", 40000)

    m1 = Manager("Dirk", "Dangerous", "675-01-1234", 140000000,
                 "Executive Assistant to the CEO", 500000)
    m2 = Manager("John", "McCEO", "896-45-8293", 15000000000, "CEO", 8000000)

    company = [e1, e2, e3, m1, m2]
    """ Gives raises to Employees and Managers, checks if raise ratio remains the same for each after giving the raise """
    for person in company:
        raiseAmt = .25

        print("Pre-Raise  > " + str(person))
        preSal = person.salary
        person.giveRaise(raiseAmt)
        print("Post-Raise > " + str(person))
        postSal = person.salary

        print(
            f"             (Post-Raise Salary - Pre-Raise Salary) / Pre-Raise Salary == {(postSal - preSal)/preSal}"
        )
"""
Test Run:
Example #38
0
 def setUp(self):
     print 'setUp'
     self.emp_1 = Employee('first', 'last', 50000)
     self.emp_2 = Employee('shayam', 'gupta', 60000)
 def setUp(self):
     self.employee = Employee("John", "Doe", 5000)
 def setUp(self):
     print('setUp')
     # runs its code before every single test
     self.emp_1 = Employee('Georgii', 'Ivannikov', 50000)
     self.emp_2 = Employee('Sange', 'Andyasha', 60000)
Example #41
0
def add_employee(emp):

    conn = sqlite3.connect('employee.db')
    cur = conn.cursor()
    cur.execute("insert into employees values (?,?,?)",
                (emp.first, emp.last, emp.pay))
    cur.execute("insert into employees values (:first,:last,:pay)", {
        'first': emp_2.first,
        'last': emp_2.last,
        'pay': emp_2.pay
    })
    conn.commit()
    conn.close()


def view_table():
    conn = sqlite3.connect('employee.db')
    cur = conn.cursor()
    cur.execute("select *from employees where last=?", ('mohd', ))
    #cur.execute("select *from employees where last=:last",{'last':'mohd'})
    print(cur.fetchall())
    conn.commit()
    conn.close()


#create_table()
emp_1 = Employee('Sam', 'Smith', 90000)
emp_2 = Employee('Jane', 'Smith', 80000)
add_employee(emp_1)
view_table()
 def setUp(self):
     self.test_emp = Employee("Dan", "Gaylord", 60000)
     self.amount = 10000
from employee import Employee
emp_list=list()
crob=Employee()
prob=Employee()
upob=Employee()
while (True):
	
	print('''
	..............................
	>_ Please select the options :
	1) Create Employee
	2) Update Employee
	3) Print All Employee
	4) Exit the program
	..............................\n
		''')
	option=int(input())
	if(option==1):
		ce=crob.createEmployee()
		emp_list.append(ce)
	elif(option==2):
		print(">_ Enter Employee ID to update information")
		emp_id=int(input())
		ue=upob.updateEmployee(emp_id)
		for dic in emp_list:
			if(dic.keys() == ue.keys()):
				emp_list.remove(dic)
				emp_list.append(ue)
				print("\n>_UPDATED LIST :\n",emp_list) 		
	elif(option==3):
		prob.printEmployee(emp_list)
Example #44
0
 def __str__(self):
     #Converts a manager object into a string that lists out the Employee and Manager class attributes
     return (Employee.__str__(self)+ "\n** Manager Properties:\n** Title:.....%s\n** Bonus:.....%s" % (self.title,str(self.bonus)))
Example #45
0
	def test_giveRaiseE(self):
		e1 = Employee("Adam", "Smith", "123-456-7890", 80000)
		e1.giveRaise(5)
		self.assertEqual(84000, e1.salary, "Failed")
Example #46
0
from employee import Employee

print("Invoke using object")
emp1 = Employee("Prasanna", "Mohanasundaram",21870,30)
emp1.getInfo()

emp2 = Employee("FIRSTNAME","LASTNAME",11223,99)
emp2.getInfo()

emp2.setInfo(55)

emp2.getInfo()


Example #47
0
#!/usr/bin/python

from employee import Employee 

emp1 = Employee("Bob", 50000);
emp2 = Employee("Mary", 60000);

print emp1;
print emp2;

emp1.displayEmployee();
emp2.displayEmployee();
emp1.displayCount();

# Because python is dynamic and all you can add attributes to an 
# existing instance
emp1.age = 25;

class TestEmployee(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        print('setupClass')

    @classmethod
    def tearDownClass(cls):
        print('teardownClass')

    def setUp(self):
        print('setUp')
        self.emp_1 = Employee('Corey', 'Schafer', 50000)
        self.emp_2 = Employee('Sue', 'Smith', 60000)

    def tearDown(self):
        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):
        with patch('employee.requests.get') as mocked_get:
            mocked_get.return_value.ok = True
            mocked_get.return_value.text = 'Success'

            schedule = self.emp_1.monthly_schedule('May')
            mocked_get.assert_called_with('http://company.com/Schafer/May')
            self.assertEqual(schedule, 'Success')

            mocked_get.return_value.ok = False

            schedule = self.emp_2.monthly_schedule('June')
            mocked_get.assert_called_with('http://company.com/Smith/June')
            self.assertEqual(schedule, 'Bad Response!')
Example #49
0
    celsius = kelvin - 273.0
    fahrenheit = celsius * 9 / 5 + 32 
    return celsius, fahrenheit

c, f = calculate_temperature(340)

print c, f 

me = Person('Tim', 'Reilly', '503 314 3771')

fullname = me.full_name()
print fullname 

from employee import Employee

tim_employed = Employee('Tim', 'Reilly', '503 314 3771', 100000000)

print tim_employed.salary

tim_employed.give_raise(999)

print tim_employed.salary

print tim_employed


#Files!

f = open('test.txt', 'w') # w for overwrite
f.write('This file is now at Galvanize')
f.close()
Example #50
0
	def setUp(self):
		"""Create default employee instance."""
		self.employee = Employee('zheng hong', 'tan', 7000)
Example #51
0
 def __init__(self, name,ssn,salary,title, bonus):
     Employee.__init__(self, name,ssn,salary)
     self.title = title
     self.bonus = bonus
Example #52
0
# Example retrieved from https://www.python-course.eu/python3_inheritance.php
# Date retrieved: Nov 15, 2018
# Example slightly modified

# More examples available here: https://pythonspot.com/polymorphism/

from person import Person
from employee import Employee

employees = []

employees[0] = Person("Marge", "Simpson", 36)
employees[1] = Employee("Homer", "Simpson", 28, "1007")

for item in employees:
    print(item)
 def setUp(self):
     print('setUp')
     self.emp_1 = Employee('Corey', 'Schafer', 50000)
     self.emp_2 = Employee('Sue', 'Smith', 60000)
Example #54
0
def is_valid_nric(nric):
    valid = False
    if len(nric) != 9:
        print('Length must be 9')
    elif nric[0] != 'S' and nric[0] != 'T':
        print('First character must be S or T')
    elif not nric[-1].isalpha():
        print('Last character must be a alphabetic letter')
    else:
        valid = True

    return valid


print(Employee('11', 'Eleven', 0))
print(Student('12', 'Twelve', 2))

empl_list = []
stud_list = []

option = 'Y'

while option.upper() != 'N':

    valid_nric = False
    while not valid_nric:
        nric = input('Enter NRIC: ')
        valid_nric = is_valid_nric(nric)

    name = input('Enter Name: ')
Example #55
0
    def setUp(self):
        """
		Create a set of employee record for use in all test methods.
		"""
        self.employee_survey = Employee('Saquib', 'Herman', 700000)
Example #56
0
#!/usr/bin/python

from employee import Employee

emp1 = Employee("Zara", 2000)
emp2 = Employee("Manni", 5000)

emp1.displayEmployee()
emp2.displayEmployee()
Example #57
0
	def __str__(self):
		"""
		Returns the object's data in a string.
		"""
		return Employee.__str__(self) + "Title: %s\nBonus: %s\n" %\
				(self.title, self.bonus)

"""
Creates one employee and manager object. Calls methods on them for 
testing purposes. Creates list of employees and managers and sorts
them in alphabetical order according to lastnames.
"""

if __name__ == "__main__":
	e1 = Employee("Jane", "Adams", "597-938-9202", 60000)
	print(e1)

	e1.giveRaise(5)
	print(e1)

	m1 = Manager("Joe", "Smith", "657-393-0191", 70000, "Supervisor", 700)
	print(m1)

	m1.giveRaise(10)
	print(m1)

	m2 = Manager("Joe", "Stuart", "697-808-978", 90766, "TL", 1000)
	print(m2 == m1)
	print(m1 < m2)
	print(m2 < e1)
Example #58
0
conn = sqlite3.connect(
    'employee.db'
)  # If you want a fresh DB done for each run that purely lives in RAM, use ":memory: instead of 'employee.db"

c = conn.cursor()

# You only need to run this the first time you run the script.
# c.execute("""CREATE TABLE employees (
#             first text,
#             last text,
#             pay interget
#             )""") # 3 quotes is a docstring.

# Build Python Objects
emp_1 = Employee('Steve', 'asdf', 46789)
emp_2 = Employee('Ben', ';lkjlka;lsk', 32123)

# Inserts a data set into DB
# c.execute("INSERT INTO employees VALUES(?, ?, ?)", (emp_1.first, emp_1.last, emp_1.pay)) # Note: Don't use string formatting when pushing data into your table in python
# conn.commit()

# Alternate Method to Insert Data
# c.execute("INSERT INTO employees VALUES (:first, :last, :pay)", {'first':emp_2.first, 'last':emp_2.last, 'pay':emp_2.pay})
# conn.commit()

# Hardcoded SQL Query
c.execute("SELECT * FROM employees")
# print(c.fetchall())
data = c.fetchall()
for datum in data:
Example #59
0
	def __str__(self):
		"""
		Returns the object's data in a string.
		"""
		return Employee.__str__(self) + "Title: %s\nBonus: %s\n" %\
				(self.title, self.bonus)
 def setUp(self):
     self.emp_1 = Employee('Amaka', 'Ohiku', 150000)
     self.emp_2 = Employee('Sue', 'Smith', 60000)