Example #1
0
    def test_update_employee(self):
        serialized_employee = fixtures.load("unactivated_user")
        employee = EmployeeProvider.deserialize(serialized_employee)
        employee = EmployeeProvider.update_with(employee, name="New Name")
        self.assertEqual(employee.name, "New Name")

        employee = EmployeeProvider.update_with(employee,
                                                employment_date=datetime(
                                                    2019, 1, 30))
        self.assertEqual(employee.employment_date, datetime(2019, 1, 30))
        self.assertEqual(employee.rate, RateCalculator.MAX_DAYS)

        employee = EmployeeProvider.update_with(employee, email="*****@*****.**")
        self.assertEqual(employee.email, "*****@*****.**")

        employee = EmployeeProvider.update_with(employee,
                                                password="******")
        self.assertEqual(employee.password, "new_password")

        employee = EmployeeProvider.activate(employee)
        self.assertEqual(employee.activated, True)

        employee = EmployeeProvider.deactivate(employee)
        self.assertEqual(employee.activated, False)

        self.assertEqual(employee.is_admin, False)

        employee = EmployeeProvider.set_balance_vac(employee, 10)
        self.assertEqual(employee.vacation, 10)
Example #2
0
    def build(self):
        session = super().build()
        admin_user = EmployeeProvider.deserialize(fixtures.load("admin_user"))
        unaccepted_user = EmployeeProvider.deserialize(
            fixtures.load("unaccepted_user"))
        user_with_vacation = EmployeeProvider.deserialize(
            fixtures.load("user_with_vacation"))
        session.add(admin_user)
        session.add(unaccepted_user)
        session.add(user_with_vacation)
        session.commit()

        january_ts = TimeSheetProvider.deserialize(
            fixtures.load('january_time_sheet'))
        half_january_ts = TimeSheetProvider.deserialize(
            fixtures.load('half_january_time_sheet'))
        session.add(january_ts)
        session.add(half_january_ts)
        session.commit()
        return session
Example #3
0
 def test_register_employee_without_balance_vacation(self):
     serialized_employee = fixtures.load("unaccepted_user")
     employee = EmployeeProvider.deserialize(serialized_employee)
     now_date = datetime.now()
     employee = EmployeeProvider.register(employee=employee,
                                          employment_date=now_date)
     self.assertIsNotNone(employee)
     self.assertEqual(employee.acceptance_date.year, now_date.year)
     self.assertEqual(employee.acceptance_date.month, now_date.month)
     self.assertEqual(employee.acceptance_date.day, now_date.day)
     self.assertEqual(employee.employment_date, now_date)
     self.assertEqual(employee.activated, True)
     self.assertEqual(employee.is_admin, False)
     self.assertEqual(employee.vacation, 0)
Example #4
0
    def test_deserialize_unaccepted_employee(self):
        serialized_employee = fixtures.load("unaccepted_user")
        employee = EmployeeProvider.deserialize(serialized_employee)

        self.assertIsNotNone(employee)
        self.assertEqual(employee.id, 1)
        self.assertEqual(employee.name, 'Unregistered User')
        self.assertEqual(employee.password, 'user')
        self.assertEqual(employee.email, '*****@*****.**')
        self.assertFalse(employee.activated)
        self.assertFalse(employee.is_admin)
        self.assertIsNone(employee.vacation)
        self.assertIsNone(employee.employment_date)
        self.assertIsNone(employee.acceptance_date)
Example #5
0
    def test_deserialize_employee(self):
        serialized_employee = fixtures.load("unactivated_user")
        employee = EmployeeProvider.deserialize(serialized_employee)

        self.assertIsNotNone(employee)
        self.assertEqual(employee.id, 2)
        self.assertEqual(employee.name, 'Unactivated User')
        self.assertEqual(employee.password, 'user')
        self.assertEqual(employee.email, '*****@*****.**')
        self.assertEqual(datetime(2019, 1, 1), employee.employment_date)
        self.assertEqual(datetime(2019, 1, 1), employee.acceptance_date)
        self.assertEqual(employee.vacation, 1.0)
        self.assertEqual(employee.activated, False)
        self.assertEqual(employee.is_admin, False)
Example #6
0
 def test_pick_up_admin_employee(self):
     serialized_employee = fixtures.load("admin_user")
     employee = EmployeeProvider.deserialize(serialized_employee)
     employee = EmployeeProvider.pick_up_admin(employee)
     self.assertFalse(employee.is_admin)
Example #7
0
 def test_grant_to_admin_employee(self):
     serialized_employee = fixtures.load("unaccepted_user")
     employee = EmployeeProvider.deserialize(serialized_employee)
     employee = EmployeeProvider.grant_to_admin(employee)
     self.assertTrue(employee.is_admin)