Fix marking canceled lesson only as changed
This commit is contained in:
parent
b70f3be069
commit
e282a7a50e
3 changed files with 38 additions and 11 deletions
|
@ -134,13 +134,18 @@ class TimetableParser {
|
|||
return getLessonWithReplacement(lesson, spans, 1)
|
||||
}
|
||||
|
||||
private fun getLessonLight(lesson: Timetable, spans: Elements, info: String) = lesson.copy(
|
||||
subject = getLessonAndGroupInfoFromSpan(spans[0])[0],
|
||||
group = getLessonAndGroupInfoFromSpan(spans[0])[1],
|
||||
room = spans[1].text(),
|
||||
info = getFormattedLessonInfo(info),
|
||||
changes = info.isNotBlank()
|
||||
)
|
||||
private fun getLessonLight(lesson: Timetable, spans: Elements, info: 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],
|
||||
room = spans[1].text(),
|
||||
info = getFormattedLessonInfo(info),
|
||||
canceled = isCanceled,
|
||||
changes = (info.isNotBlank() && !isCanceled) || CLASS_CHANGES in firstElementClasses
|
||||
)
|
||||
}
|
||||
|
||||
private fun getLesson(lesson: Timetable, spans: Elements, offset: Int = 0, infoExtraOffset: Int = 0, changes: String = "") = lesson.copy(
|
||||
subject = getLessonAndGroupInfoFromSpan(spans[0])[0],
|
||||
|
|
|
@ -25,13 +25,13 @@ class TimetableTest : BaseLocalTest() {
|
|||
private const val TUESDAY_OFFSET = 5
|
||||
private const val WEDNESDAY_OFFSET = 10
|
||||
private const val THURSDAY_OFFSET = 15
|
||||
private const val FRIDAY_OFFSET = 19
|
||||
private const val FRIDAY_OFFSET = 20
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getTimetableTest() {
|
||||
assertEquals(5, headers.size)
|
||||
assertEquals(23, timetable.size)
|
||||
assertEquals(24, timetable.size)
|
||||
assertEquals(2, additional.size)
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ class TimetableTest : BaseLocalTest() {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun getLightLesson_withChanges() {
|
||||
fun getLightLesson_withChanges_butWithoutClasses() {
|
||||
with(timetable[TUESDAY_OFFSET + 4]) {
|
||||
// wtorek, 4
|
||||
assertEquals(4, number)
|
||||
|
@ -533,6 +533,28 @@ class TimetableTest : BaseLocalTest() {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getLightLesson_withChanges_withInvClass() {
|
||||
with(timetable[THURSDAY_OFFSET + 4]) {
|
||||
// czwartek, 4
|
||||
assertEquals(4, number)
|
||||
assertEquals(getDate(2018, 9, 27, 10, 50, 0), start)
|
||||
assertEquals(getDate(2018, 9, 27, 11, 35, 0), end)
|
||||
|
||||
assertEquals("Fizyka", subject)
|
||||
assertEquals("", group)
|
||||
assertEquals("", teacher)
|
||||
assertEquals("A10", room)
|
||||
assertEquals("nieobecność nauczyciela: uczniowie przychodzą później", info)
|
||||
assertEquals("", subjectOld)
|
||||
assertEquals("", teacherOld)
|
||||
assertEquals("", roomOld)
|
||||
|
||||
assertEquals(true, canceled)
|
||||
assertEquals(false, changes)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getDayHeader_empty() {
|
||||
with(headers[0]) {
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
"<div><span class=''>Fizyka</span> <span class=''>A10</span></div>",
|
||||
"<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>",
|
||||
""
|
||||
]
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue