-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
Check Date for opening_hours:signed #5903
base: master
Are you sure you want to change the base?
Conversation
Tests for opening_hours quest
Thank you! Will look over this PR soon. Added tests would help (me) a big deal, because good tests are also good documentation of the behavior. The tests are nothing special, just normal (Java-like) unit tests. If you are confused about |
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.
It should also be documented by the tests how the quest(s) behave with current tagging, e.g.
shop=kiosk
opening_hours:signed=no
check_date:opening_hours=2022-02-02
In other words, taking care of the "migration path" from the old tagging to new tagging.
app/src/main/java/de/westnordost/streetcomplete/quests/opening_hours/AddOpeningHours.kt
Show resolved
Hide resolved
app/src/main/java/de/westnordost/streetcomplete/quests/opening_hours/AddOpeningHours.kt
Show resolved
Hide resolved
...in/java/de/westnordost/streetcomplete/quests/opening_hours_signed/CheckOpeningHoursSigned.kt
Outdated
Show resolved
Hide resolved
Currently AFK from my programming machine for a week, I shall check your comments then. |
will add tests as requested in a few. |
Tests added. CheckOpeningSigned now checks for both check_dates (or older 1 year), that why for second test mentioned (in my eyes) correctly asserts true not false because it's older than a year and has no check_dates at all. |
When setting opening_hours:signed=no and it's check_date, remove check_date for opening_hours as it's no longer relevant even if existing opening_hours don't get deleted
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.
Tests for
- that
check_date:opening_hours
is removed when answeringNoOpeningHoursSign
- that
check_date:opening_hours:signed
is removed when answering with anything else
are missing inAddOpeningHoursTest
When you add new behavior to tested code, always also test this new behavior (not only modify the tests so that they run through green again). If the tests are not kept up-to-date with the implementation, the tests don't make sense.
Also, the new tests you added are puzzling to me.
AddOpeningHours
quest should NEVER be applicable while opening_hours:signed=no
, because when it is not signed, it should never be asked. Instead, we have CheckOpeningHoursSigned
which is asked in its place. When the user answered that it is signed now, only then AddOpeningHours
should be asked again.
Instead of this desired behavior, the tests seem to test that the quest is being asked also for places with unsigned opening hours as long as it was checked more than one year ago.
@Test fun `is applicable if the opening hours not signed and only check date for OH exists`() { | ||
assertTrue(questType.isApplicableTo(node( | ||
tags = mapOf( | ||
"name" to "rundumdieuhr kiosk", | ||
"opening_hours:signed" to "no", | ||
"check_date:opening_hours" to "2021-03-01" | ||
), | ||
timestamp = "2000-11-11".toCheckDate()?.toEpochMilli() | ||
))) | ||
} |
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.
This test doesn't test what you want it to test. You want it to test that it takes the older of the two of check_date:opening_hours
and check_date:opening_hours:signed
, but to test this, timestamp
would need to be "now" (i.e. the default). Otherwise the quest would anyway be applicable because the last edit date is 24 years old.
@Test fun `is applicable if the opening hours not signed and only check date for OH exists`() { | |
assertTrue(questType.isApplicableTo(node( | |
tags = mapOf( | |
"name" to "rundumdieuhr kiosk", | |
"opening_hours:signed" to "no", | |
"check_date:opening_hours" to "2021-03-01" | |
), | |
timestamp = "2000-11-11".toCheckDate()?.toEpochMilli() | |
))) | |
} | |
@Test fun `is applicable if the opening hours not signed and only check date for OH exists`() { | |
assertTrue(questType.isApplicableTo(node( | |
tags = mapOf( | |
"name" to "rundumdieuhr kiosk", | |
"opening_hours:signed" to "no", | |
"check_date:opening_hours" to "2021-03-01" | |
) | |
))) | |
} |
Resolves #4273, ref #4276.
Is this, what we were looking for?
If the answer is that
opening_hours:signed=no
(either from quest/opening_hours or quest/opening_hours_signed) we addcheck_date:opening_hours:signed
.If the answer is that
opening_hours:signed=yes
(either from quest/opening_hours or quest/opening_hours_signed), that meansopening_hours:signed
is removed andopening_hours=*
are set, we removecheck_date:opening_hours:signed
and try to setcheck_date:opening_hours
to the last edit timestamp so that the apply check for opening_hours works.quest/opening_hours_signed checks for this info being older than a year OR the element being last edited over a year.
quest/opening_hours now either filters for
opening_hours:signed != no
OR (opening_hours:signed = no
ANDcheck_date:opening_hours:signed
older than 1 year)Testing with applicable objects, the behaviour seems to be programmatically correct, yet, I am unable to formulate the Tests correctly, I might need help in understading how these work. I have thrown away my changes in the tests and will work on them again later -> WIP PR.
Also, please provide feedback on the setting/removing/interpretation of the various check dates.