mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Issue 1576: Solving problems with habitbull import (#1591)
* Recomputing the habit after import, corrected order of magnitude * Corrected HabitBullCSV3 test and added a new one
This commit is contained in:
3
uhabits-core/assets/test/habitbull4.csv
Normal file
3
uhabits-core/assets/test/habitbull4.csv
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
HabitName,HabitDescription,HabitCategory,CalendarDate,Value,CommentText
|
||||||
|
Caffeine,,Coffee Consumption,2022-11-21,80,
|
||||||
|
Caffeine,,Coffee Consumption,2022-11-22,80,
|
||||||
|
@@ -86,10 +86,12 @@ class HabitBullCSVImporter
|
|||||||
logger.info("Found a value of $value, considering this habit as numerical.")
|
logger.info("Found a value of $value, considering this habit as numerical.")
|
||||||
h.type = HabitType.NUMERICAL
|
h.type = HabitType.NUMERICAL
|
||||||
}
|
}
|
||||||
h.originalEntries.add(Entry(timestamp, value, notes))
|
h.originalEntries.add(Entry(timestamp, value * 1000, notes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
map.forEach { (_, habit) -> habit.recompute() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseTimestamp(rawValue: String): Timestamp {
|
private fun parseTimestamp(rawValue: String): Timestamp {
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ class ImportTest : BaseUnitTest() {
|
|||||||
assertThat(habit.type, equalTo(HabitType.NUMERICAL))
|
assertThat(habit.type, equalTo(HabitType.NUMERICAL))
|
||||||
assertThat(habit.description, equalTo(""))
|
assertThat(habit.description, equalTo(""))
|
||||||
assertThat(habit.frequency, equalTo(Frequency.DAILY))
|
assertThat(habit.frequency, equalTo(Frequency.DAILY))
|
||||||
assertThat(getValue(habit, 2021, 9, 1), equalTo(30))
|
assertThat(getValue(habit, 2021, 9, 1), equalTo(30000))
|
||||||
assertThat(getValue(habit, 2022, 1, 8), equalTo(100))
|
assertThat(getValue(habit, 2022, 1, 8), equalTo(100000))
|
||||||
|
|
||||||
val habit2 = habitList.getByPosition(1)
|
val habit2 = habitList.getByPosition(1)
|
||||||
assertThat(habit2.name, equalTo("run"))
|
assertThat(habit2.name, equalTo("run"))
|
||||||
@@ -98,6 +98,21 @@ class ImportTest : BaseUnitTest() {
|
|||||||
assertTrue(isChecked(habit2, 2022, 1, 19))
|
assertTrue(isChecked(habit2, 2022, 1, 19))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(IOException::class)
|
||||||
|
fun testHabitBullCSV4() {
|
||||||
|
importFromFile("habitbull4.csv")
|
||||||
|
assertThat(habitList.size(), equalTo(1))
|
||||||
|
|
||||||
|
val habit = habitList.getByPosition(0)
|
||||||
|
assertThat(habit.name, equalTo("Caffeine"))
|
||||||
|
assertThat(habit.type, equalTo(HabitType.NUMERICAL))
|
||||||
|
assertThat(habit.description, equalTo(""))
|
||||||
|
assertThat(habit.frequency, equalTo(Frequency.DAILY))
|
||||||
|
assertThat(getValue(habit, 2022, 11, 21), equalTo(80000))
|
||||||
|
assertThat(getValue(habit, 2022, 11, 22), equalTo(80000))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun testLoopDB() {
|
fun testLoopDB() {
|
||||||
|
|||||||
Reference in New Issue
Block a user