Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating time zone #123

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

OfirBachar
Copy link
Contributor

Updating time zone to Israel by changing the TIME_ZONE in settings.py file

Signed-off-by: Ofir Bachar <[email protected]>
@patrisiakaplun
Copy link
Contributor

@idosinger98 can help please?
FAILED reservation/test_schedule_model.py::TestScheduleModel::test_get_free_meetings_by_professional_and_date

@idosinger98
Copy link
Contributor

@idosinger98 can help please? FAILED reservation/test_schedule_model.py::TestScheduleModel::test_get_free_meetings_by_professional_and_date

It won't work without pytz installed

@OfirBachar
Copy link
Contributor Author

@idosinger98 can help please? FAILED reservation/test_schedule_model.py::TestScheduleModel::test_get_free_meetings_by_professional_and_date

It won't work without pytz installed

I have installed pytz and it still failed.

@OfirBachar
Copy link
Contributor Author

OfirBachar commented May 31, 2023

@idosinger98 can help please? FAILED reservation/test_schedule_model.py::TestScheduleModel::test_get_free_meetings_by_professional_and_date

It won't work without pytz installed

it is not about the pytz
image

Copy link
Contributor

@idosinger98 idosinger98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not the updated tests, there are new tests in PR 132

@Yarboa
Copy link
Contributor

Yarboa commented Jun 5, 2023

It's not the updated tests, there are new tests in PR 132

@OfirBachar maybe rebase will help here

@OfirBachar
Copy link
Contributor Author

It's not the updated tests, there are new tests in PR 132

@OfirBachar maybe rebase will help here

I rebased. Apparently, that wasn't the problem.
@idosinger98 please take a look. if you want I am free to a small zoom call.

@idoyek
Copy link
Contributor

idoyek commented Jun 6, 2023

@idosinger98 The problem in one of your tests, reservation/test_make_appointment.py::TestMakeAppointment::test_confirm_appointment_view,
is that in your model you use the models.DateTimeField(). If you notice, when you migrated, you had multiple warnings about it. You can either change the model again, or do this in the test: I imported localtime and changed 2 lines to be in the local time-
assert localtime(appointment.start_appointment).hour == 10
assert localtime(appointment.end_appointment).hour == 11
it worked for me. this is the whole test_make_appointment.py file:

import pytest
from django.urls import reverse
from reservation.models import Appointment
from django.utils.timezone import localtime

@pytest.fixture
def save_schedule(schedule):
schedule.professional_id.save()
schedule.save()
return schedule

@pytest.mark.django_db
class TestMakeAppointment:
def test_make_appointment_view(self, client, make_client, professional):
client1 = make_client()
client.force_login(client1.profile_id.user_id)
response = client.get(reverse('make_appointment', kwargs={'pk': professional.pk}))
assert response.status_code == 200
assert 'reservation/make_appointment.html' in response.templates[0].name

def test_confirm_appointment_view(self, client, make_client, professional, save_schedule, make_typeOfJob):
    client1 = make_client()
    client.force_login(client1.profile_id.user_id)
    typeOfJob1 = make_typeOfJob()

    data = {
        'service': typeOfJob1.pk  # Include the typeOfJob selected by the user
    }

    response = client.get(reverse('confirm_appointment', kwargs={
        'professional_id': professional.pk,
        'day': save_schedule.start_day.day,
        'month': save_schedule.start_day.month,
        'year': save_schedule.start_day.year,
        'meeting': "10:00-11:00"
    }))
    assert response.status_code == 200
    assert 'reservation/confirm_appointment.html' in response.templates[0].name

    response = client.post(reverse('confirm_appointment', kwargs={
        'professional_id': professional.pk,
        'day': save_schedule.start_day.day,
        'month': save_schedule.start_day.month,
        'year': save_schedule.start_day.year,
        'meeting': '10:00-11:00'
    }), data=data)

    assert response.status_code == 302
    assert response.url == reverse('make_appointment', args=[professional.pk])
    assert Appointment.objects.filter(professional_id=professional).count() == 1
    appointment = Appointment.objects.filter(professional_id=professional).first()
    assert appointment.professional_id.professional_id == professional.pk
    assert appointment.start_appointment.year == save_schedule.start_day.year
    assert appointment.start_appointment.month == save_schedule.start_day.month
    assert appointment.start_appointment.day == save_schedule.start_day.day
    assert localtime(appointment.start_appointment).hour == 10
    assert appointment.start_appointment.minute == 0
    assert appointment.end_appointment.year == save_schedule.start_day.year
    assert appointment.end_appointment.month == save_schedule.start_day.month
    assert appointment.end_appointment.day == save_schedule.start_day.day
    assert localtime(appointment.end_appointment).hour == 11
    assert appointment.end_appointment.minute == 0
    assert appointment.client_id == client1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants