Skip to content

Commit

Permalink
Add unsigned to signed tests for opening hours
Browse files Browse the repository at this point in the history
  • Loading branch information
peternewman authored Aug 13, 2022
1 parent c2def44 commit 9409485
Showing 1 changed file with 135 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,35 @@ class AddOpeningHoursTest {
)
}

@Test fun `apply description answer when it was not signed before`() {
questType.verifyAnswer(
mapOf("opening_hours:signed" to "no"),
DescribeOpeningHours("my cool \"opening\" hours"),
StringMapEntryAdd("opening_hours", "\"my cool opening hours\""),
StringMapEntryDelete("opening_hours:signed")
)
}

@Test fun `apply description answer when it was not signed but already had an opening hours`() {
questType.verifyAnswer(
mapOf("opening_hours" to "my opening hours"),
mapOf("opening_hours:signed" to "no"),
DescribeOpeningHours("my cool \"opening\" hours"),
StringMapEntryModify("opening_hours", "my opening hours", "\"my cool opening hours\""),
StringMapEntryDelete("opening_hours:signed")
)
}

@Test fun `apply same description answer again when it was not signed before`() {
questType.verifyAnswer(
mapOf("opening_hours" to "\"oh\""),
mapOf("opening_hours:signed" to "no"),
DescribeOpeningHours("oh"),
StringMapEntryModify("opening_hours", "\"oh\"", "\"oh\""),
StringMapEntryDelete("opening_hours:signed")
)
}

@Test fun `apply no opening hours sign answer`() {
questType.verifyAnswer(
NoOpeningHoursSign,
Expand All @@ -64,6 +93,15 @@ class AddOpeningHoursTest {
)
}

@Test fun `apply no opening hours sign answer when there was an always open answer before`() {
questType.verifyAnswer(
mapOf("opening_hours" to "24/7"),
NoOpeningHoursSign,
StringMapEntryAdd("opening_hours:signed", "no"),
StringMapEntryAdd("check_date:opening_hours", LocalDate.now().toCheckDateString())
)
}

@Test fun `apply always open answer`() {
questType.verifyAnswer(
AlwaysOpen,
Expand All @@ -88,6 +126,35 @@ class AddOpeningHoursTest {
)
}

@Test fun `apply always open answer when it was not signed before`() {
questType.verifyAnswer(
mapOf("opening_hours:signed" to "no"),
AlwaysOpen,
StringMapEntryAdd("opening_hours", "24/7"),
StringMapEntryDelete("opening_hours:signed")
)
}

@Test fun `apply always open answer when it was not signed but present before`() {
questType.verifyAnswer(
mapOf("opening_hours" to "24/7"),
mapOf("opening_hours:signed" to "no"),
AlwaysOpen,
StringMapEntryModify("opening_hours", "24/7", "24/7"),
StringMapEntryDelete("opening_hours:signed")
)
}

@Test fun `apply always open answer when it was not signed but there was a different answer before`() {
questType.verifyAnswer(
mapOf("opening_hours" to "34/3"),
mapOf("opening_hours:signed" to "no"),
AlwaysOpen,
StringMapEntryModify("opening_hours", "34/3", "24/7"),
StringMapEntryDelete("opening_hours:signed")
)
}

@Test fun `apply opening hours answer`() {
questType.verifyAnswer(
RegularOpeningHours(OpeningHoursRuleList(listOf(
Expand Down Expand Up @@ -151,6 +218,74 @@ class AddOpeningHoursTest {
)
}

@Test fun `apply opening hours answer when it was not signed before`() {
questType.verifyAnswer(
mapOf("opening_hours:signed" to "no"),
RegularOpeningHours(OpeningHoursRuleList(listOf(
Rule().apply {
days = listOf(WeekDayRange().also {
it.startDay = WeekDay.MO
})
times = listOf(TimeSpan().also {
it.start = 60 * 10
it.end = 60 * 12
})
},
Rule().apply {
days = listOf(WeekDayRange().also {
it.startDay = WeekDay.TU
})
times = listOf(TimeSpan().also {
it.start = 60 * 12
it.end = 60 * 24
})
})
)),
StringMapEntryAdd("opening_hours", "Mo 10:00-12:00; Tu 12:00-24:00"),
StringMapEntryDelete("opening_hours:signed")
)
}

@Test fun `apply opening hours answer when it was not signed but there was a different one before`() {
questType.verifyAnswer(
mapOf("opening_hours" to "hohoho"),
mapOf("opening_hours:signed" to "no"),
RegularOpeningHours(OpeningHoursRuleList(listOf(
Rule().apply {
days = listOf(WeekDayRange().also {
it.startDay = WeekDay.MO
})
times = listOf(TimeSpan().also {
it.start = 60 * 10
it.end = 60 * 12
})
})
)),
StringMapEntryModify("opening_hours", "hohoho", "Mo 10:00-12:00"),
StringMapEntryDelete("opening_hours:signed")
)
}

@Test fun `apply opening hours answer when it was not signed but there was the same one before`() {
questType.verifyAnswer(
mapOf("opening_hours" to "Mo 10:00-12:00"),
mapOf("opening_hours:signed" to "no"),
RegularOpeningHours(OpeningHoursRuleList(listOf(
Rule().apply {
days = listOf(WeekDayRange().also {
it.startDay = WeekDay.MO
})
times = listOf(TimeSpan().also {
it.start = 60 * 10
it.end = 60 * 12
})
})
)),
StringMapEntryModify("opening_hours", "Mo 10:00-12:00", "Mo 10:00-12:00"),
StringMapEntryDelete("opening_hours:signed")
)
}

@Test fun `isApplicableTo returns false for unknown places`() {
assertFalse(questType.isApplicableTo(node(
tags = mapOf("whatisthis" to "something")
Expand Down

0 comments on commit 9409485

Please sign in to comment.