def testing_legajo(self, employee): for n in range(len(employee)): Administration().add_employee(employee[n]) NumLeg = [*Administration().listEmployee.keys()] NumLegRange = [n for n in range(len(NumLeg))] self.assertEqual(NumLeg, NumLegRange)
def test_add_employee(self, name, surname, age, phone, legajo): person = Person(name, surname, age, phone) personDict = person.get_person() administration = Administration() administration.add_employee(personDict) self.assertDictEqual(administration.listEmployee[legajo], personDict)
def test_legajo(self, empleados): adm = Administration() #Reemplaza el nombre de la funcion para comodidad de tipeo. for n in range(len(empleados)): adm.add_employee(empleados[n]) #Crea la lista con los Legajos generados de cada empleado. print (empleados) NL = [*adm.listEmployee.keys()] #NL = Numero de Legajo. Separa los Legajos(Claves/Keys) y los guarda en una lista. NLR = [n for n in range (len(NL))] #NLC = Numero de Legajo Registrado. self.assertListEqual (NL, NLR) #Compara ambas listas para comprobar si son iguales. print (NL, NLR)
def main(): bot.add_cog(Input(bot)) bot.add_cog(Output(bot)) bot.add_cog(Administration(bot)) bot.add_cog(Usage(bot)) bot.run(TOKEN) db_cursor.close() db_connection.close()
def test_add_employee(self, name, surname, age, phone, salary, legajo): emp = Employee("Oriel", "Barroso", 23, 155, 23000, 0).get_employee() emp2 = Employee("Nicolas", "Barroso", 32, 156, 32000, 1).get_employee() adm = Administration() adm.add_employee(emp) adm.add_employee(emp2) self.assertTrue(adm.listEmployee)
class TestAdm(unittest.TestCase): def setUp(self): self.adm = Administration() # self.adm.add_employee(Employee("Gonzalo", 19, "Juarez", 666, 20000).get_employee()) # self.adm.add_employee(Employee("X", 22, "Y", 666, 35000).get_employee()) # opción útil para inicializar previo a cada test en lugar de en parameterized.expand # (parameterize.expand crea cuantas copias de la función sean necesarias para los distintos parámetros) def tearDown(self): self.adm = None @parameterized.expand([ param([ Employee("Gonzalo", 19, "Juarez", 666, 20000).get_employee(), Employee("X", 22, "Y", 666, 35000).get_employee() ]) ]) def test_legajo(self, employee_arr): for i in range(len(employee_arr)): self.adm.add_employee(employee_arr[i]) key_list = [*self.adm.listEmployee] self.assertListEqual(key_list, [i for i in range(len(key_list))])
def setUp(self): self.adm = Administration()
def test_add_employee(self, name, surname, age, phone, salary, legajo, result): employee = Employee(name, surname, age, phone, salary) adm = Administration() adm.add_employee(employee.get_employee()) self.assertEqual(adm.listEmployee[legajo], result)
def test_add_employee(self, name, surname, age, phone, salary, legajo): employee = Employee(name, surname, age, phone, salary) adm = Administration() dictEmployee = employee.get_employee() adm.add_employee(dictEmployee) self.assertDictEqual(adm.listEmployee[legajo], dictEmployee)
import unittest from employee import Employee from administration import Administration from parameterized import parameterized class TestAdminitration(unittest.TestCase): @parameterized.expand([('Mariano', 'Saez', 20, 2995922296, 30000, 0), ('Agustin', 'Prieto', 20, 261756890, 29999, 1), ('Matias', 'Robbio', 19, 2613424565, 90000, 2), ('Bruno', 'Bonil', 19, 261890098, 100000, 3)]) def test_add_employee(self, name, surname, age, phone, salary, legajo): # Creamos una instancia de employee llamada empleado empleado = Employee(name, surname, age, phone, salary) # Agregamos a empleado a la lista de empleados de la instancia de # Administration que se crea en el main adm.add_employee(empleado) # Dado que conocemos el legajo que se asignara a empleado podemos # comparar si el elemento almacenado en # la key = legajo es igual a empleado (deberia ser el mismo) self.assertEqual(adm.listemployee[legajo], empleado) if __name__ == '__main__': # Instanciamos Administration adm = Administration() unittest.main()
from administration import Administration from limousine import Limousine from truck import Truck admin = Administration() mercedes = Limousine("Mercedes", "A-Class", 2018, "abc-123", False, 58891.7, True, True) ford = Truck("Ford", "F-150", 2015, "123-abc", True, 118723.4, False, False) dodge = Truck("Dodge", "RAM 1500", 2019, "def-456", False, 46218.8, False, True) print("\n\033[1mVoertuigen toevoegen:\033[0m") print(admin.AddVehicle(mercedes)) print(admin.AddVehicle(ford)) print(admin.AddVehicle(dodge)) print("\n\033[1mToegevoegde voertuigen lijst:\033[0m") admin.IndexVehicle() print("\n\033[1mTeruggebrachte voertuigen verwerken:\033[0m") print(admin.ReturnVehicle(mercedes, False, 156.3)) print(admin.ReturnVehicle(ford, True, 89.1)) print(admin.ReturnVehicle(dodge, False, 35.7)) print("\n\033[1mVoertuigen verhuren:\033[0m") print(admin.RentVehicle(mercedes)) print(admin.RentVehicle(ford)) print(admin.RentVehicle(dodge))
def test_administration(self, name, surname, age, phone, salary, key): for i in range(len(list(Administration().listEmployee))): empleado = Employee(name, surname, age, phone, salary).get_employee() administ = Administration().add_employee(empleado) asertEqual(administ[i], i)
def test_administration(self,name,surname,age,phone,salary, key): empleado1 = Employee(name,surname,age,phone,salary) admin=Administration() admin.add_employee(empleado1) self.assertEqual(empleado1, admin.listEmployee[key])
def test_add_employee(self, name, surname, age, phone, salary, legajo): empleado = Employee(name, surname, age, phone, salary) admin = Administration() admin.add_employee(empleado) self.assertEqual(Administration.listEmployee[legajo], empleado)