forked from github/wulkanowy-mirror
Don't copy teacher from previous lesson to completed (#341)
This commit is contained in:
parent
bf6b857a3e
commit
1f5088cfc9
@ -7,7 +7,7 @@ import org.threeten.bp.LocalDateTime.now
|
||||
import io.github.wulkanowy.api.timetable.Timetable as TimetableRemote
|
||||
import io.github.wulkanowy.data.db.entities.Timetable as TimetableLocal
|
||||
|
||||
fun createTimetableLocal(number: Int, start: LocalDateTime, room: String = "", subject: String = ""): TimetableLocal {
|
||||
fun createTimetableLocal(number: Int, start: LocalDateTime, room: String = "", subject: String = "", teacher: String = ""): TimetableLocal {
|
||||
return TimetableLocal(
|
||||
studentId = 1,
|
||||
diaryId = 2,
|
||||
@ -20,7 +20,7 @@ fun createTimetableLocal(number: Int, start: LocalDateTime, room: String = "", s
|
||||
group = "",
|
||||
room = room,
|
||||
roomOld = "",
|
||||
teacher = "",
|
||||
teacher = teacher,
|
||||
teacherOld = "",
|
||||
info = "",
|
||||
changes = false,
|
||||
@ -28,7 +28,7 @@ fun createTimetableLocal(number: Int, start: LocalDateTime, room: String = "", s
|
||||
)
|
||||
}
|
||||
|
||||
fun createTimetableRemote(number: Int, start: LocalDateTime, room: String, subject: String = ""): TimetableRemote {
|
||||
fun createTimetableRemote(number: Int, start: LocalDateTime, room: String, subject: String = "", teacher: String = ""): TimetableRemote {
|
||||
return TimetableRemote(
|
||||
number = number,
|
||||
start = start.toDate(),
|
||||
@ -37,7 +37,7 @@ fun createTimetableRemote(number: Int, start: LocalDateTime, room: String, subje
|
||||
subject = subject,
|
||||
group = "",
|
||||
room = room,
|
||||
teacher = "",
|
||||
teacher = teacher,
|
||||
info = "",
|
||||
changes = false,
|
||||
canceled = false
|
||||
|
@ -63,23 +63,27 @@ class TimetableRepositoryTest {
|
||||
fun copyDetailsToCompletedFromPrevious() {
|
||||
timetableLocal.saveTimetable(listOf(
|
||||
createTimetableLocal(1, of(2019, 3, 5, 8, 0), "123", "Przyroda"),
|
||||
createTimetableLocal(1, of(2019, 3, 5, 8, 50), "321", "Religia"),
|
||||
createTimetableLocal(1, of(2019, 3, 5, 9, 40), "213", "W-F")
|
||||
createTimetableLocal(2, of(2019, 3, 5, 8, 50), "321", "Religia"),
|
||||
createTimetableLocal(3, of(2019, 3, 5, 9, 40), "213", "W-F"),
|
||||
createTimetableLocal(4, of(2019, 3, 5, 10, 30), "213", "W-F", "Jan Kowalski")
|
||||
))
|
||||
|
||||
every { mockApi.getTimetable(any(), any()) } returns Single.just(listOf(
|
||||
createTimetableRemote(1, of(2019, 3, 5, 8, 0), "", "Przyroda"),
|
||||
createTimetableRemote(1, of(2019, 3, 5, 8, 50), "", "Religia"),
|
||||
createTimetableRemote(1, of(2019, 3, 5, 9, 40), "", "W-F")
|
||||
createTimetableRemote(2, of(2019, 3, 5, 8, 50), "", "Religia"),
|
||||
createTimetableRemote(3, of(2019, 3, 5, 9, 40), "", "W-F"),
|
||||
createTimetableRemote(4, of(2019, 3, 5, 10, 30), "", "W-F")
|
||||
))
|
||||
|
||||
val lessons = TimetableRepository(settings, timetableLocal, timetableRemote)
|
||||
.getTimetable(semesterMock, LocalDate.of(2019, 3, 5), LocalDate.of(2019, 3, 5), true)
|
||||
.blockingGet()
|
||||
|
||||
assertEquals(3, lessons.size)
|
||||
assertEquals(4, lessons.size)
|
||||
assertEquals("123", lessons[0].room)
|
||||
assertEquals("321", lessons[1].room)
|
||||
assertEquals("213", lessons[2].room)
|
||||
|
||||
assertEquals("", lessons[3].teacher)
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,7 @@ class TimetableRepository @Inject constructor(
|
||||
item.apply {
|
||||
old.singleOrNull { this.start == it.start }?.let {
|
||||
return@map copy(
|
||||
room = if (room.isEmpty()) it.room else room,
|
||||
teacher = if (teacher.isEmpty()) it.teacher else teacher
|
||||
room = if (room.isEmpty()) it.room else room
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user