Skip to content

Commit a28d84c

Browse files
committed
Creates Employee, Role, Department and attendance
1 parent 49c8ede commit a28d84c

25 files changed

+1137
-1
lines changed

.coverage

76 KB
Binary file not shown.

.coveragerc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[run]
3+
omit =
4+
tests\seed_db.py
5+
insert_db_data.py
6+
database\common.py

common/attendance.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ def get_attendance_by_date_all_employees(db: Session, punch_date: datetime, user
148148

149149
def get_attendance_by_date_one_employee(db: Session, employee_id: int, punch_date: datetime, user:user_dependency):
150150
_require_admin(user=user)
151+
employee = db.query(Employee).filter(Employee.employee_id == employee_id).first()
152+
if not employee:
153+
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,detail="Employee not found")
151154
start_dt = datetime.combine(punch_date, time.min)
152155
end_dt = datetime.combine(punch_date, time.max)
153156

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_auth_token(client, email: str, password: str) -> str:
8282
# TOKEN FIXTURE (optional)
8383
# ------------------------------
8484
@pytest.fixture
85-
def admin_token(client):
85+
def admin_user(client):
8686
return get_auth_token(client, "admin@test.com", "pass123")
8787

8888

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
[
2+
{
3+
"punch_time": "2023-01-01T10:00:00",
4+
"attendance_id": 1,
5+
"fk_employee_id": 1
6+
},
7+
{
8+
"punch_time": "2023-01-01T07:00:00",
9+
"attendance_id": 2,
10+
"fk_employee_id": 1
11+
},
12+
{
13+
"punch_time": "2023-01-01T10:20:00",
14+
"attendance_id": 3,
15+
"fk_employee_id": 1
16+
},
17+
{
18+
"punch_time": "2023-01-01T07:20:00",
19+
"attendance_id": 4,
20+
"fk_employee_id": 1
21+
},
22+
{
23+
"punch_time": "2023-01-10T10:00:00",
24+
"attendance_id": 5,
25+
"fk_employee_id": 2
26+
},
27+
{
28+
"punch_time": "2023-01-10T07:10:00",
29+
"attendance_id": 6,
30+
"fk_employee_id": 2
31+
},
32+
{
33+
"punch_time": "2023-01-10T10:20:00",
34+
"attendance_id": 7,
35+
"fk_employee_id": 2
36+
},
37+
{
38+
"punch_time": "2023-01-10T07:20:00",
39+
"attendance_id": 8,
40+
"fk_employee_id": 2
41+
},
42+
{
43+
"punch_time": "2023-01-10T10:00:00",
44+
"attendance_id": 9,
45+
"fk_employee_id": 3
46+
},
47+
{
48+
"punch_time": "2023-01-10T07:10:00",
49+
"attendance_id": 10,
50+
"fk_employee_id": 3
51+
},
52+
{
53+
"punch_time": "2023-01-10T10:20:00",
54+
"attendance_id": 11,
55+
"fk_employee_id": 3
56+
},
57+
{
58+
"punch_time": "2023-01-10T07:20:00",
59+
"attendance_id": 12,
60+
"fk_employee_id": 3
61+
},
62+
{
63+
"punch_time": "2023-04-01T10:00:00",
64+
"attendance_id": 13,
65+
"fk_employee_id": 4
66+
},
67+
{
68+
"punch_time": "2023-04-01T07:10:00",
69+
"attendance_id": 14,
70+
"fk_employee_id": 4
71+
},
72+
{
73+
"punch_time": "2023-04-03T10:20:00",
74+
"attendance_id": 15,
75+
"fk_employee_id": 4
76+
},
77+
{
78+
"punch_time": "2023-04-03T07:20:00",
79+
"attendance_id": 16,
80+
"fk_employee_id": 4
81+
},
82+
{
83+
"punch_time": "2023-04-01T10:00:00",
84+
"attendance_id": 17,
85+
"fk_employee_id": 6
86+
},
87+
{
88+
"punch_time": "2023-04-01T07:10:00",
89+
"attendance_id": 18,
90+
"fk_employee_id": 6
91+
},
92+
{
93+
"punch_time": "2023-04-03T10:20:00",
94+
"attendance_id": 19,
95+
"fk_employee_id": 6
96+
},
97+
{
98+
"punch_time": "2023-04-03T07:20:00",
99+
"attendance_id": 20,
100+
"fk_employee_id": 6
101+
},
102+
{
103+
"punch_time": "2023-04-02T10:00:00",
104+
"attendance_id": 21,
105+
"fk_employee_id": 5
106+
},
107+
{
108+
"punch_time": "2023-04-02T07:10:00",
109+
"attendance_id": 22,
110+
"fk_employee_id": 5
111+
},
112+
{
113+
"punch_time": "2023-04-06T10:20:00",
114+
"attendance_id": 23,
115+
"fk_employee_id": 5
116+
},
117+
{
118+
"punch_time": "2023-04-06T07:20:00",
119+
"attendance_id": 24,
120+
"fk_employee_id": 5
121+
},
122+
{
123+
"punch_time": "2023-04-02T10:00:00",
124+
"attendance_id": 25,
125+
"fk_employee_id": 7
126+
},
127+
{
128+
"punch_time": "2023-04-02T07:10:00",
129+
"attendance_id": 26,
130+
"fk_employee_id": 7
131+
},
132+
{
133+
"punch_time": "2023-04-06T10:20:00",
134+
"attendance_id": 27,
135+
"fk_employee_id": 7
136+
},
137+
{
138+
"punch_time": "2023-04-06T07:20:00",
139+
"attendance_id": 28,
140+
"fk_employee_id": 7
141+
}
142+
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[
2+
{
3+
"punch_time": "2023-01-10T07:10:00",
4+
"attendance_id": 6,
5+
"fk_employee_id": 2
6+
},
7+
{
8+
"punch_time": "2023-01-10T07:20:00",
9+
"attendance_id": 8,
10+
"fk_employee_id": 2
11+
},
12+
{
13+
"punch_time": "2023-01-10T10:00:00",
14+
"attendance_id": 5,
15+
"fk_employee_id": 2
16+
},
17+
{
18+
"punch_time": "2023-01-10T10:20:00",
19+
"attendance_id": 7,
20+
"fk_employee_id": 2
21+
},
22+
{
23+
"punch_time": "2023-01-10T07:10:00",
24+
"attendance_id": 10,
25+
"fk_employee_id": 3
26+
},
27+
{
28+
"punch_time": "2023-01-10T07:20:00",
29+
"attendance_id": 12,
30+
"fk_employee_id": 3
31+
},
32+
{
33+
"punch_time": "2023-01-10T10:00:00",
34+
"attendance_id": 9,
35+
"fk_employee_id": 3
36+
},
37+
{
38+
"punch_time": "2023-01-10T10:20:00",
39+
"attendance_id": 11,
40+
"fk_employee_id": 3
41+
}
42+
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"punch_time": "2023-01-01T10:00:00",
4+
"attendance_id": 1,
5+
"fk_employee_id": 1
6+
},
7+
{
8+
"punch_time": "2023-01-01T07:00:00",
9+
"attendance_id": 2,
10+
"fk_employee_id": 1
11+
},
12+
{
13+
"punch_time": "2023-01-01T10:20:00",
14+
"attendance_id": 3,
15+
"fk_employee_id": 1
16+
},
17+
{
18+
"punch_time": "2023-01-01T07:20:00",
19+
"attendance_id": 4,
20+
"fk_employee_id": 1
21+
}
22+
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"punch_time": "2023-01-01T07:00:00",
4+
"attendance_id": 2,
5+
"fk_employee_id": 1
6+
},
7+
{
8+
"punch_time": "2023-01-01T07:20:00",
9+
"attendance_id": 4,
10+
"fk_employee_id": 1
11+
},
12+
{
13+
"punch_time": "2023-01-01T10:00:00",
14+
"attendance_id": 1,
15+
"fk_employee_id": 1
16+
},
17+
{
18+
"punch_time": "2023-01-01T10:20:00",
19+
"attendance_id": 3,
20+
"fk_employee_id": 1
21+
}
22+
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"punch_time": "2023-04-01T07:10:00",
4+
"attendance_id": 14,
5+
"fk_employee_id": 4
6+
},
7+
{
8+
"punch_time": "2023-04-01T07:10:00",
9+
"attendance_id": 18,
10+
"fk_employee_id": 6
11+
},
12+
{
13+
"punch_time": "2023-04-01T10:00:00",
14+
"attendance_id": 13,
15+
"fk_employee_id": 4
16+
},
17+
{
18+
"punch_time": "2023-04-01T10:00:00",
19+
"attendance_id": 17,
20+
"fk_employee_id": 6
21+
}
22+
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"punch_time": "2023-01-10T10:00:00",
4+
"attendance_id": 9,
5+
"fk_employee_id": 3
6+
},
7+
{
8+
"punch_time": "2023-01-10T07:10:00",
9+
"attendance_id": 10,
10+
"fk_employee_id": 3
11+
},
12+
{
13+
"punch_time": "2023-01-10T10:20:00",
14+
"attendance_id": 11,
15+
"fk_employee_id": 3
16+
},
17+
{
18+
"punch_time": "2023-01-10T07:20:00",
19+
"attendance_id": 12,
20+
"fk_employee_id": 3
21+
}
22+
]

0 commit comments

Comments
 (0)