Fix marking canceled lesson only as changed
(cherry picked from commit e282a7a50e
)
This commit is contained in:
parent
2d9b7bebad
commit
48c1e71520
4 changed files with 39 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -71,3 +71,4 @@ gradle-app.setting
|
|||
*iml
|
||||
classes
|
||||
.DS_Store
|
||||
.idea/libraries-with-intellij-classes.xml
|
||||
|
|
|
@ -133,13 +133,18 @@ class TimetableParser {
|
|||
return getLessonWithReplacement(lesson, spans, 1)
|
||||
}
|
||||
|
||||
private fun getLessonLight(lesson: Timetable, spans: Elements, info: String) = lesson.copy(
|
||||
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),
|
||||
changes = info.isNotBlank()
|
||||
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,12 +25,12 @@ 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(23, timetable.size)
|
||||
assertEquals(24, timetable.size)
|
||||
assertEquals(18, timetableBefore1911.size)
|
||||
}
|
||||
|
||||
|
@ -489,7 +489,7 @@ class TimetableTest : BaseLocalTest() {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun getLightLesson_withChanges() {
|
||||
fun getLightLesson_withChanges_butWithoutClasses() {
|
||||
with(timetable[TUESDAY_OFFSET + 4]) {
|
||||
// wtorek, 4
|
||||
assertEquals(4, number)
|
||||
|
@ -532,6 +532,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 getAdditionalLesson() {
|
||||
with(additional[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