mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Update HabitBullCSV test to accept notes
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
HabitName,HabitDescription,HabitCategory,CalendarDate,Value,CommentText
|
HabitName,HabitDescription,HabitCategory,CalendarDate,Value,CommentText
|
||||||
Breed dragons,with love and fire,Diet & Food,2016-03-18,1,
|
Breed dragons,with love and fire,Diet & Food,2016-03-18,1,text
|
||||||
Breed dragons,with love and fire,Diet & Food,2016-03-19,1,
|
Breed dragons,with love and fire,Diet & Food,2016-03-19,1,
|
||||||
Breed dragons,with love and fire,Diet & Food,2016-03-21,1,
|
Breed dragons,with love and fire,Diet & Food,2016-03-21,1,
|
||||||
Reduce sleep,only 2 hours per day,Time Management,2016-03-15,1,
|
Reduce sleep,only 2 hours per day,Time Management,2016-03-15,1,
|
||||||
|
|||||||
|
@@ -1,7 +1,7 @@
|
|||||||
HabitName,HabitDescription,HabitCategory,CalendarDate,Value,CommentText
|
HabitName,HabitDescription,HabitCategory,CalendarDate,Value,CommentText
|
||||||
H1,,C1,11/5/2020,1,
|
H1,,C1,11/5/2020,1,
|
||||||
H2,,C2,11/5/2020,-2150000000,
|
H2,,C2,11/5/2020,-2150000000,
|
||||||
H3,Habit 3,C3,4/11/2019,1,
|
H3,Habit 3,C3,4/11/2019,1,text
|
||||||
H3,Habit 3,C3,4/12/2019,1,
|
H3,Habit 3,C3,4/12/2019,1,
|
||||||
H3,Habit 3,C3,4/13/2019,0,
|
H3,Habit 3,C3,4/13/2019,0,
|
||||||
H3,Habit 3,C3,4/14/2019,1,
|
H3,Habit 3,C3,4/14/2019,1,
|
||||||
@@ -65,7 +65,7 @@ H3,Habit 3,C3,6/10/2019,1,
|
|||||||
H3,Habit 3,C3,6/11/2019,1,
|
H3,Habit 3,C3,6/11/2019,1,
|
||||||
H3,Habit 3,C3,6/12/2019,1,
|
H3,Habit 3,C3,6/12/2019,1,
|
||||||
H3,Habit 3,C3,6/13/2019,1,
|
H3,Habit 3,C3,6/13/2019,1,
|
||||||
H3,Habit 3,C3,6/14/2019,0,
|
H3,Habit 3,C3,6/14/2019,0,Habit 3 notes
|
||||||
H3,Habit 3,C3,6/15/2019,1,
|
H3,Habit 3,C3,6/15/2019,1,
|
||||||
H4,Habit 4,C4,11/6/2020,1,
|
H4,Habit 4,C4,11/6/2020,1,
|
||||||
H4,Habit 4,C4,11/9/2020,1,
|
H4,Habit 4,C4,11/9/2020,1,
|
||||||
|
|||||||
|
@@ -76,9 +76,11 @@ class HabitBullCSVImporter
|
|||||||
map[name] = h
|
map[name] = h
|
||||||
logger.info("Creating habit: $name")
|
logger.info("Creating habit: $name")
|
||||||
}
|
}
|
||||||
|
val notes = cols[5] ?: ""
|
||||||
if (parseInt(cols[4]) == 1) {
|
if (parseInt(cols[4]) == 1) {
|
||||||
val notes = cols[5] ?: ""
|
|
||||||
h.originalEntries.add(Entry(timestamp, Entry.YES_MANUAL, notes))
|
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, 18))
|
||||||
assertTrue(isChecked(habit, 2016, 3, 19))
|
assertTrue(isChecked(habit, 2016, 3, 19))
|
||||||
assertFalse(isChecked(habit, 2016, 3, 20))
|
assertFalse(isChecked(habit, 2016, 3, 20))
|
||||||
|
assertTrue(isNotesEqual(habit, 2016, 3, 18, "text"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -68,6 +69,8 @@ class ImportTest : BaseUnitTest() {
|
|||||||
assertTrue(isChecked(habit, 2019, 4, 11))
|
assertTrue(isChecked(habit, 2019, 4, 11))
|
||||||
assertTrue(isChecked(habit, 2019, 5, 7))
|
assertTrue(isChecked(habit, 2019, 5, 7))
|
||||||
assertFalse(isChecked(habit, 2019, 6, 14))
|
assertFalse(isChecked(habit, 2019, 6, 14))
|
||||||
|
assertTrue(isNotesEqual(habit, 2019, 4, 11, "text"))
|
||||||
|
assertTrue(isNotesEqual(habit, 2019, 6, 14, "Habit 3 notes"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -127,6 +130,13 @@ class ImportTest : BaseUnitTest() {
|
|||||||
return h.originalEntries.get(timestamp).value == Entry.YES_MANUAL
|
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)
|
@Throws(IOException::class)
|
||||||
private fun importFromFile(assetFilename: String) {
|
private fun importFromFile(assetFilename: String) {
|
||||||
val file = File.createTempFile("asset", "")
|
val file = File.createTempFile("asset", "")
|
||||||
|
|||||||
Reference in New Issue
Block a user