-
Notifications
You must be signed in to change notification settings - Fork 7
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
Creating orders.html, presenting orders history #95
base: main
Are you sure you want to change the base?
Conversation
a147283
to
650070c
Compare
9a0d554
to
d36c343
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @OfirMatasas!
take a look at the comment I left.
d36c343
to
b3b9cb5
Compare
7bb5e24
to
5264358
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job ofir! orders HTML looks good , I left 1 comment tell me what you think
Capacity dates check for show only available daycares in dates range. "get_capacity_of_daycare_in_dates_range" function took from redhat-beyond#95 . waiting for approval. Signed-off-by: tamirmatok <[email protected]>
Capacity dates check for show only available daycares in dates range. "get_capacity_of_daycare_in_dates_range" function took from redhat-beyond#95 . waiting for approval. Signed-off-by: tamirmatok <[email protected]>
Capacity dates check for show only available daycares in dates range. "get_capacity_of_daycare_in_dates_range" function took from redhat-beyond#95 . waiting for approval. Signed-off-by: tamirmatok <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @OfirMatasas !!
I left some comments let me know what u think.
322dfc1
to
453b3a4
Compare
Capacity dates check for show only available daycares in dates range. "get_capacity_of_daycare_in_dates_range" function took from #95 . waiting for approval. Signed-off-by: tamirmatok <[email protected]>
create_order.status = new_status | ||
assert create_order.get_order_status() == expected_result | ||
|
||
def test_get_daycare_capacity_in_dates_range(self, create_order): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not how you should test this function. it has a lot of logic; you need to test different cases and see that you get the capacity you expect in each case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that checking the current capacity of a daycare before and after approving an order will check if the method is working correctly.
Also, some of the other tests are testing this method too (like "test_order_is_approvable_according_to_daycare_capacity").
Do you have any example for a case that I should test for this method? Or another way for testing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first of all - test names should follow the method they're testing (but not only the method name).
as an example:
if the method name is: check_capacity_of_daycare
possible test names are:
test_check_capacity_of_daycare
test_check_capacity_of_daycare_raise_value_error_when_something_happends
test_check_capacity_of_daycare_reduced_after_an_order
etc.
otherwise, it is very confusing to understand what is testing what.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second:
the test above test if order can be approved, according to its overall calculated capacity
this test should be a specific unit-test for get_capacity_of_daycare_in_dates_range
it doesn't test the overall logic your app will go through, but it is testing this method specifically, and should pass even if in the future you'll decide to change the way the process works.
this method has a lot of cases. think of each if
statement as at least two possible test-cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OfirMatasas are you going to address these?
|
||
return capacity_per_day | ||
|
||
def are_order_dates_available(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made "test_order_is_approvable_according_to_daycare_capacity" for this method. Should I test it in another way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it testing this function alone?
if it does, it deserves a name change :)
Otherwise, we need a test to test this only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing this function does is check if specific dates are available due to capacity. the test you wrote deal with the whole process your application does. What we need for this function is a unit test, as it tests this unit specifically, without dependencies from other processes.
Capacity dates check for show only available daycares in dates range. "get_capacity_of_daycare_in_dates_range" function took from #95 . waiting for approval. Signed-off-by: tamirmatok <[email protected]>
Capacity dates check for show only available daycares in dates range. "get_capacity_of_daycare_in_dates_range" function took from #95 . waiting for approval. Signed-off-by: tamirmatok <[email protected]>
Capacity dates check for show only available daycares in dates range. "get_capacity_of_daycare_in_dates_range" function took from redhat-beyond#95 . waiting for approval. Signed-off-by: tamirmatok <[email protected]>
Capacity dates check for show only available daycares in dates range. "get_capacity_of_daycare_in_dates_range" function took from redhat-beyond#95 . waiting for approval. Signed-off-by: tamirmatok <[email protected]>
Capacity dates check for show only available daycares in dates range. "get_capacity_of_daycare_in_dates_range" function took from redhat-beyond#95 . waiting for approval. Signed-off-by: tamirmatok <[email protected]>
A page on Hotails, where the user can watch the history of all of his orders, cancel the orders which havn't started yet, and approve orders as a daycare. Signed-off-by: Ofir Matasas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Ofir, please see my inline comments
def get_order_status(self): | ||
if self.status == StatusOptions.Pending: | ||
return "Pending" | ||
elif self.status == StatusOptions.Approved: | ||
return "Approved" | ||
elif self.status == StatusOptions.Canceled: | ||
return "Canceled" | ||
elif self.status == StatusOptions.OnGoing: | ||
return "Ongoing" | ||
return "Finished" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified to
statusOptionsNameIdx=1
reuturn self.status[statusOptionsNameIdx]
WDYT?
return "Finished" | ||
|
||
@staticmethod | ||
def get_capacity_of_daycare_in_dates_range(daycare_id: DayCare, start_datetime: datetime, end_datetime: datetime): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is capacity?
start_date = datetime.date(year=start_datetime.year, month=start_datetime.month, day=start_datetime.day) | ||
end_date = datetime.date(year=end_datetime.year, month=end_datetime.month, day=end_datetime.day) | ||
relevant_orders = Order.objects.filter(daycare_id=daycare_id, | ||
status__in=['A', 'O'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use full names?
create_order.status = new_status | ||
assert create_order.get_order_status() == expected_result | ||
|
||
def test_get_daycare_capacity_in_dates_range(self, create_order): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OfirMatasas are you going to address these?
def orders(request): | ||
if DogOwner.objects.filter(user=request.user).exists(): | ||
context = { | ||
'orders': Order.objects.filter(dog_owner_id__user=request.user), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it necessary to fillter by authenticated user, is it possible to use request.user
directly?
There are conflicts and a bunch of unresolved comments. Sorry, it won't be ready for the demo. |
A page on Hotails, where the user can watch the history of all of his
orders, cancel the orders which havn't started yet, and approve orders
as a daycare.
Signed-off-by: Ofir Matasas [email protected]
Desired Outcome
A page on Hotails, where the user can watch the history of all of his orders, cancel the orders which haven't started yet, and approve orders as a daycare.
Implemented Changes
Connected Issue/Story
Closes #94
Definition of Done
All the options mentioned in the desired outcome are available to the users.
Picture of the orders page