Fix marking as non-changed if cell don't have classes
(cherry picked from commit bb083546e0
)
This commit is contained in:
parent
48c1e71520
commit
c918ba39f4
3 changed files with 37 additions and 11 deletions
|
@ -146,15 +146,19 @@ class TimetableParser {
|
|||
)
|
||||
}
|
||||
|
||||
private fun getLesson(lesson: Timetable, spans: Elements, offset: Int = 0, infoExtraOffset: Int = 0, changes: String = "") = lesson.copy(
|
||||
subject = getLessonAndGroupInfoFromSpan(spans[0])[0],
|
||||
group = getLessonAndGroupInfoFromSpan(spans[0])[1],
|
||||
teacher = spans[1 + offset].text(),
|
||||
room = spans[2 + offset].text(),
|
||||
info = getFormattedLessonInfo(spans.getOrNull(3 + offset + infoExtraOffset)?.text() ?: changes),
|
||||
canceled = spans.first().hasClass(CLASS_MOVED_OR_CANCELED),
|
||||
changes = spans.first().hasClass(CLASS_CHANGES)
|
||||
)
|
||||
private fun getLesson(lesson: Timetable, spans: Elements, offset: Int = 0, infoExtraOffset: Int = 0, changes: String = ""): Timetable {
|
||||
val firstElementClasses = spans.first().classNames()
|
||||
val isCanceled = CLASS_MOVED_OR_CANCELED in firstElementClasses
|
||||
return lesson.copy(
|
||||
subject = getLessonAndGroupInfoFromSpan(spans[0])[0],
|
||||
group = getLessonAndGroupInfoFromSpan(spans[0])[1],
|
||||
teacher = spans[1 + offset].text(),
|
||||
room = spans[2 + offset].text(),
|
||||
info = getFormattedLessonInfo(spans.getOrNull(3 + offset + infoExtraOffset)?.text() ?: changes),
|
||||
canceled = isCanceled,
|
||||
changes = (changes.isNotBlank() && !isCanceled) || CLASS_CHANGES in firstElementClasses
|
||||
)
|
||||
}
|
||||
|
||||
private fun getLessonWithReplacement(lesson: Timetable, spans: Elements, o: Int = 0) = lesson.copy(
|
||||
subject = getLessonAndGroupInfoFromSpan(spans[3 + o])[0],
|
||||
|
|
|
@ -30,7 +30,7 @@ class TimetableTest : BaseLocalTest() {
|
|||
|
||||
@Test
|
||||
fun getTimetableTest() {
|
||||
assertEquals(24, timetable.size)
|
||||
assertEquals(25, timetable.size)
|
||||
assertEquals(18, timetableBefore1911.size)
|
||||
}
|
||||
|
||||
|
@ -554,6 +554,28 @@ class TimetableTest : BaseLocalTest() {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getLightLesson_withoutClasses_withSubstitution() {
|
||||
with(timetable[FRIDAY_OFFSET + 4]) {
|
||||
// piątek, 4
|
||||
assertEquals(4, number)
|
||||
assertEquals(getDate(2018, 9, 28, 10, 50, 0), start)
|
||||
assertEquals(getDate(2018, 9, 28, 11, 35, 0), end)
|
||||
|
||||
assertEquals("pracownia programowania", subject)
|
||||
assertEquals("JA 2", group)
|
||||
assertEquals("", teacher)
|
||||
assertEquals("B149", room)
|
||||
assertEquals("zastępstwo: Tabaluga Jakub", info)
|
||||
assertEquals("", subjectOld)
|
||||
assertEquals("", teacherOld)
|
||||
assertEquals("", roomOld)
|
||||
|
||||
assertEquals(false, canceled)
|
||||
assertEquals(true, changes)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getAdditionalLesson() {
|
||||
with(additional[0]) {
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
"<div><span class=''>podstawy algorytmiki i programowania</span> <span class=''>A114</span>(zastępstwo: Stanisław Baran)</div>",
|
||||
"<div><span class='x-treelabel-ppl x-treelabel-inv'>Język angielski [JA 2]</span><span class='x-treelabel-ppl x-treelabel-inv'> </span><span class='x-treelabel-ppl x-treelabel-inv'> A315</span>(nieobecność nauczyciela: czytelnia)</div>",
|
||||
"<div><span class='x-treelabel-ppl x-treelabel-inv'>Fizyka</span> <span class='x-treelabel-ppl x-treelabel-inv'>A10</span>(nieobecność nauczyciela: uczniowie przychodzą później)</div>",
|
||||
""
|
||||
"<div><span class=''>pracownia programowania [JA 2]</span><span class=''> </span><span class=''> B149</span>(zastępstwo: Tabaluga Jakub)</div>"
|
||||
]
|
||||
],
|
||||
"Additionals": [
|
||||
|
|
Loading…
Reference in a new issue