Timetable fixes
- Only one request is made to get the timetable HTML document for parsing the timetable and the weekNumberYear - On timeouts or other errors, the cached data won't be overwritten with emptiness anymore - The scheduled updates will now also update the weekNumberYear
This commit is contained in:
@ -32,8 +32,8 @@ class TimetableParserTest {
|
||||
@Test
|
||||
fun parseTimetableNormalWeek() {
|
||||
val htmlFile = File(TimetableParserTest::class.java.getResource("/html/Timetable_normal-week.html").path)
|
||||
val htmlDoc = Jsoup.parse(htmlFile,"UTF-8", "https://www.hs-offenburg.de/")
|
||||
val actualTimetable = TimetableParser().parseTimeTable(htmlDoc).toString().trim()
|
||||
val htmlDoc = Jsoup.parse(htmlFile, "UTF-8", "https://www.hs-offenburg.de/")
|
||||
val actualTimetable = TimetableParser(htmlDoc = htmlDoc).parseTimeTable().toString().trim()
|
||||
val expectedTimetable = TimetableParserTest::class.java.getResource("/expected/Timetable_normal-week.txt").readText().trim()
|
||||
|
||||
Assertions.assertEquals(expectedTimetable, actualTimetable)
|
||||
@ -42,8 +42,8 @@ class TimetableParserTest {
|
||||
@Test
|
||||
fun parseTimetableEmptyWeek() {
|
||||
val htmlFile = File(TimetableParserTest::class.java.getResource("/html/Timetable_empty-week.html").path)
|
||||
val htmlDoc = Jsoup.parse(htmlFile,"UTF-8", "https://www.hs-offenburg.de/")
|
||||
val actualTimetable = TimetableParser().parseTimeTable(htmlDoc).toString().trim()
|
||||
val htmlDoc = Jsoup.parse(htmlFile, "UTF-8", "https://www.hs-offenburg.de/")
|
||||
val actualTimetable = TimetableParser(htmlDoc = htmlDoc).parseTimeTable().toString().trim()
|
||||
val expectedTimetable = TimetableParserTest::class.java.getResource("/expected/Timetable_empty-week.txt").readText().trim()
|
||||
|
||||
Assertions.assertEquals(expectedTimetable, actualTimetable)
|
||||
@ -52,8 +52,8 @@ class TimetableParserTest {
|
||||
@Test
|
||||
fun parseWeekNumberYear() {
|
||||
val htmlFile = File(TimetableParserTest::class.java.getResource("/html/Timetable_normal-week.html").path)
|
||||
val htmlDoc = Jsoup.parse(htmlFile,"UTF-8", "https://www.hs-offenburg.de/")
|
||||
val actualWeekNumberYear = TimetableParser().parseWeekNumberYear(htmlDoc)
|
||||
val htmlDoc = Jsoup.parse(htmlFile, "UTF-8", "https://www.hs-offenburg.de/")
|
||||
val actualWeekNumberYear = TimetableParser(htmlDoc = htmlDoc).parseWeekNumberYear()
|
||||
|
||||
Assertions.assertEquals(42, actualWeekNumberYear)
|
||||
}
|
||||
|
Reference in New Issue
Block a user