def setUp(self): self.created_at = datetime.datetime.now() self.updated_at = datetime.datetime.now() self.leader = EmployeeEntity(id=1, name="Brol", employee_id="00001", hourly_rate=50.00, employee_type=1, is_a_leader=True, created_at=self.created_at, updated_at=self.updated_at, total_work_hours=40) self.team_1 = TeamEntity( name="Greys", description= "Grey-skinned humanoids, usually 3–4 feet tall, hairless, with large heads." ) self.team_2 = TeamEntity( id=1, name="Flatwoods monster", description="Tall humanoid with a spade-shaped head.", leader=self.leader, created_at=self.created_at, updated_at=self.updated_at)
def setUp(self): self.created_at = datetime.datetime.now() self.updated_at = datetime.datetime.now() self.created_at = datetime.datetime.now() self.updated_at = datetime.datetime.now() self.employee_1 = EmployeeEntity( id=1, name="Brol", employee_id="00001", hourly_rate=50.00, employee_type=1, is_a_leader=True, created_at=self.created_at, updated_at=self.updated_at, total_work_hours=40 ) self.employee_2 = EmployeeEntity( id=2, name="Scox", employee_id="00001", hourly_rate=50.00, employee_type=2, is_a_leader=False, created_at=self.created_at, updated_at=self.updated_at, total_work_hours=20 ) self.team_1 = TeamEntity( id=1, name="Flatwoods monster", description="Tall humanoid with a spade-shaped head.", leader=None, created_at=self.created_at, updated_at=self.updated_at ) self.team_2 = TeamEntity( id=2, name="Greys", description="Grey-skinned humanoids, usually 3–4 feet tall, hairless, with large heads.", leader=None, created_at=self.created_at + datetime.timedelta(seconds=10), updated_at=self.updated_at + datetime.timedelta(seconds=10) ) teams = { 1: self.team_1, 2: self.team_2 } employees = { 1: self.employee_1, 2: self.employee_2 } self.db = MemoryDB(teams=teams, employees=employees) # copy object to avoid using the same db object in all test cases self.use_case_factory = UnittestsUseCasesFactory(db=copy.deepcopy(self.db)) self.use_case = self.use_case_factory.use_cases.manage_employee_use_case()
def setUp(self): self.created_at = datetime.datetime.now() self.updated_at = datetime.datetime.now() self.employee = EmployeeEntity(id=1, name="Brol", employee_id="00002", hourly_rate=50.00, employee_type=2, is_a_leader=False, created_at=self.created_at, updated_at=self.updated_at, total_work_hours=32) self.team = TeamEntity( id=1, name="Flatwoods monster", description="Tall humanoid with a spade-shaped head.", created_at=self.created_at, updated_at=self.updated_at) self.work_arrangement = WorkArrangementEntity(id=1, percent=80, employee=self.employee, team=self.team, remarks="Blah bla ...") self.work_time = WorkTimeEntity(id=1, hours=32, employee=self.employee, work_arrangement=self.work_arrangement)
def create(self, validated_data): """ Create and return complete instance of team Entity based on validated data :param validated_data: :return: """ return TeamEntity(**validated_data)
def to_team_entity(team_obj: Team): leader = get_team_leader(team_pk=team_obj.id) if leader: leader_entity = DataConverters.to_employee_entity(leader) else: leader_entity = None team_entity = TeamEntity(id=team_obj.id, name=team_obj.name, description=team_obj.description, created_at=team_obj.created_at, updated_at=team_obj.updated_at, leader=leader_entity) return team_entity
def setUp(self): self.created_at = datetime.datetime.now() self.updated_at = datetime.datetime.now() self.leader = EmployeeEntity(id=1, name="Brol", employee_id="00002", hourly_rate=50.00, employee_type=2, is_a_leader=False, created_at=self.created_at, updated_at=self.updated_at, total_work_hours=20) self.team = TeamEntity( id=1, name="Flatwoods monster", description="Tall humanoid with a spade-shaped head.", created_at=self.created_at, updated_at=self.updated_at) self.team_leader = TeamLeaderEntity(id=1, leader=self.leader, team=self.team, created_at=self.created_at, updated_at=self.updated_at)
def save(self, team_entity: TeamEntity): new_id = len(self.db.teams) + 1 team_entity.id = new_id self.db.teams[new_id] = team_entity return team_entity