mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 17:18:52 -06:00
Update HabitBullCSV test to accept notes
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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", "")
|
||||
|
||||
Reference in New Issue
Block a user