Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.2.3] - 2025-08-22

### Added
- Increased test coverage for the `time_log.py` module from 88% to 100%.


## [1.2.2] - 2025-08-22

### Added
Expand Down Expand Up @@ -141,6 +147,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Flexible database configuration (SQLite/PostgreSQL).



[1.2.3]: https://github.com/PPeitsch/TimeTrack/compare/v1.2.2...v1.2.3
[1.2.2]: https://github.com/PPeitsch/TimeTrack/compare/v1.2.1...v1.2.2
[1.2.1]: https://github.com/PPeitsch/TimeTrack/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/PPeitsch/TimeTrack/compare/v1.1.1...v1.2.0
Expand Down
38 changes: 38 additions & 0 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,44 @@ def test_monthly_logs_route(self):
self.assertIn("entries", entry)
self.assertIn("total_hours", entry)

def test_monthly_logs_with_absence(self):
# Create an absence entry
with self.app.app_context():
entry_date = date(2025, 4, 15)
absence_entry = ScheduleEntry(
employee_id=1, date=entry_date, entries=[], absence_code="VAC"
)
db.session.add(absence_entry)
db.session.commit()

# Test getting monthly logs for the month with the absence
response = self.client.get("/logs/monthly/2025/4")
self.assertEqual(response.status_code, 200)
data = json.loads(response.data)

# Find the absence entry in the response
absence_found = False
for entry in data:
if entry["date"] == "2025-04-15":
self.assertEqual(entry["type"], "VAC")
self.assertEqual(entry["total_hours"], 0)
absence_found = True
break
self.assertTrue(absence_found, "Absence entry not found in response")

def test_monthly_logs_exception(self):
with self.app.app_context():
with patch("app.routes.time_log.ScheduleEntry.query") as mock_query:
# Configure the mock to raise an exception when used
mock_query.filter.side_effect = Exception("Database connection failed")

# Test that the exception is handled and a 500 error is returned
response = self.client.get("/logs/monthly/2025/5")
self.assertEqual(response.status_code, 500)
data = json.loads(response.data)
self.assertIn("error", data)
self.assertEqual(data["error"], "Database connection failed")


if __name__ == "__main__":
unittest.main()