Update HabitBullCSV test to accept notes

This commit is contained in:
Bindu
2021-09-21 02:35:30 -07:00
parent a9fddf9963
commit 7cc4b66dfd
4 changed files with 16 additions and 4 deletions

View File

@@ -76,9 +76,11 @@ class HabitBullCSVImporter
map[name] = h
logger.info("Creating habit: $name")
}
val notes = cols[5] ?: ""
if (parseInt(cols[4]) == 1) {
val notes = cols[5] ?: ""
h.originalEntries.add(Entry(timestamp, Entry.YES_MANUAL, notes))
} else {
h.originalEntries.add(Entry(timestamp, Entry.NO, notes))
}
}
}

View File

@@ -54,6 +54,7 @@ class ImportTest : BaseUnitTest() {
assertTrue(isChecked(habit, 2016, 3, 18))
assertTrue(isChecked(habit, 2016, 3, 19))
assertFalse(isChecked(habit, 2016, 3, 20))
assertTrue(isNotesEqual(habit, 2016, 3, 18, "text"))
}
@Test
@@ -68,6 +69,8 @@ class ImportTest : BaseUnitTest() {
assertTrue(isChecked(habit, 2019, 4, 11))
assertTrue(isChecked(habit, 2019, 5, 7))
assertFalse(isChecked(habit, 2019, 6, 14))
assertTrue(isNotesEqual(habit, 2019, 4, 11, "text"))
assertTrue(isNotesEqual(habit, 2019, 6, 14, "Habit 3 notes"))
}
@Test
@@ -127,6 +130,13 @@ class ImportTest : BaseUnitTest() {
return h.originalEntries.get(timestamp).value == Entry.YES_MANUAL
}
private fun isNotesEqual(h: Habit, year: Int, month: Int, day: Int, notes: String): Boolean {
val date = getStartOfTodayCalendar()
date.set(year, month - 1, day)
val timestamp = Timestamp(date)
return h.originalEntries.get(timestamp).notes == notes
}
@Throws(IOException::class)
private fun importFromFile(assetFilename: String) {
val file = File.createTempFile("asset", "")