Skip to content

Commit 78889c7

Browse files
authored
Merge pull request #111 from adamspd/fix/label-in-readme
Updated label in readme
2 parents 5eaf513 + d069d49 commit 78889c7

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Python Distribution [PyPi & GH Release | TestPyPi]
1+
name: Publishing
22

33
on:
44
push:

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
running_tests:
10+
tests:
1111
runs-on: ubuntu-20.04
1212
strategy:
1313
max-parallel: 4

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
![Tests](https://github.com/adamspd/django-appointment/actions/workflows/tests.yml/badge.svg)
44
![Published on PyPi](https://github.com/adamspd/django-appointment/actions/workflows/publish.yml/badge.svg)
5-
[![PyPI version](https://badge.fury.io/py/django-appointment.svg)](https://badge.fury.io/py/django-appointment)
5+
[![Current Release Version](https://img.shields.io/github/release/adamspd/django-appointment.svg?style=flat-square&logo=github)](https://github.com/adamspd/django-appointment/releases)
6+
[![pypi Version](https://img.shields.io/pypi/v/django-appointment.svg?style=flat-square&logo=pypi&logoColor=white)](https://pypi.org/project/django-appointment/)
7+
[![PyPi downloads](https://static.pepy.tech/personalized-badge/django-appointment?period=total&units=international_system&left_color=grey&right_color=orange&left_text=pip%20downloads)](https://pypi.org/project/django-appointment/)
68
[![codecov](https://codecov.io/gh/adamspd/django-appointment/branch/main/graph/badge.svg?token=ZQZQZQZQZQ)](https://codecov.io/gh/adamspd/django-appointment)
79
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
810
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/adamspd/django-appointment)](https://github.com/adamspd/django-appointment/commits/main)

appointment/tests/test_services.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -432,71 +432,72 @@ def setUp(self):
432432
self.wh2 = WorkingHours.objects.create(staff_member=self.staff_member1, day_of_week=3,
433433
start_time=datetime.time(9, 0), end_time=datetime.time(17, 0))
434434
# But decides to take a day off next Monday
435-
DayOff.objects.create(staff_member=self.staff_member1, start_date=get_next_weekday(self.today, 0),
436-
end_date=get_next_weekday(self.today, 1))
435+
self.next_monday = get_next_weekday(self.today, 0)
436+
self.next_tuesday = get_next_weekday(self.today, 1)
437+
self.next_wednesday = get_next_weekday(self.today, 2)
438+
self.next_thursday = get_next_weekday(self.today, 3)
439+
self.next_friday = get_next_weekday(self.today, 4)
440+
self.next_saturday = get_next_weekday(self.today, 5)
441+
self.next_sunday = get_next_weekday(self.today, 6)
442+
DayOff.objects.create(staff_member=self.staff_member1, start_date=self.next_monday, end_date=self.next_monday)
437443
Config.objects.create(slot_duration=60, lead_time=datetime.time(9, 0), finish_time=datetime.time(17, 0),
438444
appointment_buffer_time=0)
439445

440446
def test_day_off(self):
441447
"""Test if a day off is handled correctly when getting available slots."""
442-
# Get a day in the future that is a Monday (for python weekday: 0 = Monday)
443-
date = get_next_weekday(datetime.datetime.today(), 0)
444448
# Ask for slots for it, and it should return an empty list since next Monday is a day off
445-
slots = get_available_slots_for_staff(date, self.staff_member1)
449+
slots = get_available_slots_for_staff(self.next_monday, self.staff_member1)
446450
self.assertEqual(slots, [])
447451

448452
def test_staff_does_not_work(self):
449453
"""Test if a staff member who doesn't work on a given day is handled correctly when getting available slots."""
450454
# For next week, the staff member works only on Monday and Wednesday, but puts a day off on Monday
451455
# So the staff member should not have any available slots except for Wednesday, which is day #2 (python weekday)
452-
slots = get_available_slots_for_staff(get_next_weekday(self.today, 1), self.staff_member1)
456+
slots = get_available_slots_for_staff(self.next_monday, self.staff_member1)
453457
self.assertEqual(slots, [])
454-
slots = get_available_slots_for_staff(get_next_weekday(self.today, 3), self.staff_member1)
458+
slots = get_available_slots_for_staff(self.next_tuesday, self.staff_member1)
455459
self.assertEqual(slots, [])
456-
slots = get_available_slots_for_staff(get_next_weekday(self.today, 4), self.staff_member1)
460+
slots = get_available_slots_for_staff(self.next_thursday, self.staff_member1)
457461
self.assertEqual(slots, [])
458-
slots = get_available_slots_for_staff(get_next_weekday(self.today, 5), self.staff_member1)
462+
slots = get_available_slots_for_staff(self.next_friday, self.staff_member1)
459463
self.assertEqual(slots, [])
460-
slots = get_available_slots_for_staff(get_next_weekday(self.today, 6), self.staff_member1)
464+
slots = get_available_slots_for_staff(self.next_saturday, self.staff_member1)
461465
self.assertEqual(slots, [])
462-
slots = get_available_slots_for_staff(get_next_weekday(self.today, 0), self.staff_member1)
466+
slots = get_available_slots_for_staff(self.next_sunday, self.staff_member1)
463467
self.assertEqual(slots, [])
464468

465469
def test_available_slots(self):
466470
"""Test if available slots are returned correctly."""
467471
# On a Wednesday, the staff member should have slots from 9 AM to 5 PM
468-
date = get_next_weekday(self.today, 2)
469-
slots = get_available_slots_for_staff(date, self.staff_member1)
472+
slots = get_available_slots_for_staff(self.next_wednesday, self.staff_member1)
470473
expected_slots = [f"{hour:02d}:00 AM" for hour in range(9, 12)] + ["12:00 PM"] + \
471474
[f"{hour:02d}:00 PM" for hour in range(1, 5)]
472475
self.assertEqual(slots, expected_slots)
473476

474477
def test_booked_slots(self):
475478
"""On a given day, if a staff member has an appointment, that time slot should not be available."""
476479
# Let's book a slot for the staff member on next Wednesday
477-
appt_date = get_next_weekday(self.today, 2)
478480
start_time = datetime.time(10, 0)
479481
end_time = datetime.time(11, 0)
480482

481483
# Create an appointment request for that time
482484
appt_request = self.create_appointment_request_(service=self.service1, staff_member=self.staff_member1,
483-
date_=appt_date, start_time=start_time, end_time=end_time)
485+
date_=self.next_wednesday, start_time=start_time, end_time=end_time)
484486
# Create an appointment using that request
485487
self.create_appointment_(user=self.client1, appointment_request=appt_request)
486488

487489
# Now, the staff member should not have that slot available
488-
slots = get_available_slots_for_staff(appt_date, self.staff_member1)
490+
slots = get_available_slots_for_staff(self.next_wednesday, self.staff_member1)
489491
expected_slots = ['09:00 AM', '11:00 AM', '12:00 PM', '01:00 PM', '02:00 PM', '03:00 PM', '04:00 PM']
490492
self.assertEqual(slots, expected_slots)
491493

492494
def test_no_working_hours(self):
493495
"""If a staff member doesn't have working hours on a given day, no slots should be available."""
494496
# Let's ask for slots on a Thursday, which the staff member doesn't work
495-
date = get_next_weekday(self.today, 3)
496497
# Let's remove the config object also since it may contain default working days
497498
Config.objects.all().delete()
498499
# Now no slots should be available
499-
slots = get_available_slots_for_staff(date, self.staff_member1)
500+
slots = get_available_slots_for_staff(self.next_thursday, self.staff_member1)
500501
self.assertEqual(slots, [])
501502

502503

0 commit comments

Comments
 (0)