mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Test CSV export file content
This commit is contained in:
@@ -0,0 +1 @@
|
||||
2015-01-25,0.0000
|
||||
|
@@ -0,0 +1,10 @@
|
||||
2015-01-25,2
|
||||
2015-01-24,0
|
||||
2015-01-23,1
|
||||
2015-01-22,2
|
||||
2015-01-21,2
|
||||
2015-01-20,2
|
||||
2015-01-19,1
|
||||
2015-01-18,1
|
||||
2015-01-17,2
|
||||
2015-01-16,2
|
||||
|
@@ -0,0 +1,10 @@
|
||||
2015-01-25,0.2557
|
||||
2015-01-24,0.2226
|
||||
2015-01-23,0.1991
|
||||
2015-01-22,0.1746
|
||||
2015-01-21,0.1379
|
||||
2015-01-20,0.0995
|
||||
2015-01-19,0.0706
|
||||
2015-01-18,0.0515
|
||||
2015-01-17,0.0315
|
||||
2015-01-16,0.0107
|
||||
|
11
uhabits-core/assets/test/csv_export/Checkmarks.csv
Normal file
11
uhabits-core/assets/test/csv_export/Checkmarks.csv
Normal file
@@ -0,0 +1,11 @@
|
||||
Date,Meditate,Wake up early,
|
||||
2015-01-25,-1,2,
|
||||
2015-01-24,-1,0,
|
||||
2015-01-23,-1,1,
|
||||
2015-01-22,-1,2,
|
||||
2015-01-21,-1,2,
|
||||
2015-01-20,-1,2,
|
||||
2015-01-19,-1,1,
|
||||
2015-01-18,-1,1,
|
||||
2015-01-17,-1,2,
|
||||
2015-01-16,-1,2,
|
||||
|
3
uhabits-core/assets/test/csv_export/Habits.csv
Normal file
3
uhabits-core/assets/test/csv_export/Habits.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
Position,Name,Question,Description,NumRepetitions,Interval,Color
|
||||
001,Meditate,Did you meditate this morning?,,1,1,#FF8F00
|
||||
002,Wake up early,Did you wake up before 6am?,,2,3,#00897B
|
||||
|
11
uhabits-core/assets/test/csv_export/Scores.csv
Normal file
11
uhabits-core/assets/test/csv_export/Scores.csv
Normal file
@@ -0,0 +1,11 @@
|
||||
Date,Meditate,Wake up early,
|
||||
2015-01-25,0.0000,0.2557,
|
||||
2015-01-24,0.0000,0.2226,
|
||||
2015-01-23,0.0000,0.1991,
|
||||
2015-01-22,0.0000,0.1746,
|
||||
2015-01-21,0.0000,0.1379,
|
||||
2015-01-20,0.0000,0.0995,
|
||||
2015-01-19,0.0000,0.0706,
|
||||
2015-01-18,0.0000,0.0515,
|
||||
2015-01-17,0.0000,0.0315,
|
||||
2015-01-16,0.0000,0.0107,
|
||||
|
@@ -34,6 +34,7 @@ import java.util.zip.ZipFile
|
||||
|
||||
class HabitsCSVExporterTest : BaseUnitTest() {
|
||||
private lateinit var baseDir: File
|
||||
|
||||
@Before
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
@@ -41,12 +42,7 @@ class HabitsCSVExporterTest : BaseUnitTest() {
|
||||
habitList.add(fixtures.createShortHabit())
|
||||
habitList.add(fixtures.createEmptyHabit())
|
||||
baseDir = Files.createTempDirectory("csv").toFile()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun tearDown() {
|
||||
FileUtils.deleteDirectory(baseDir)
|
||||
super.tearDown()
|
||||
baseDir.deleteOnExit()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,14 +59,20 @@ class HabitsCSVExporterTest : BaseUnitTest() {
|
||||
assertAbsolutePathExists(filename)
|
||||
val archive = File(filename)
|
||||
unzip(archive)
|
||||
assertPathExists("Habits.csv")
|
||||
assertPathExists("001 Meditate/Checkmarks.csv")
|
||||
assertPathExists("001 Meditate/Scores.csv")
|
||||
assertPathExists("002 Wake up early")
|
||||
assertPathExists("002 Wake up early/Checkmarks.csv")
|
||||
assertPathExists("002 Wake up early/Scores.csv")
|
||||
assertPathExists("Checkmarks.csv")
|
||||
assertPathExists("Scores.csv")
|
||||
val filesToCheck = arrayOf(
|
||||
"001 Meditate/Checkmarks.csv",
|
||||
"001 Meditate/Scores.csv",
|
||||
"002 Wake up early/Checkmarks.csv",
|
||||
"002 Wake up early/Scores.csv",
|
||||
"Checkmarks.csv",
|
||||
"Habits.csv",
|
||||
"Scores.csv"
|
||||
)
|
||||
|
||||
for (file in filesToCheck) {
|
||||
assertPathExists(file)
|
||||
assertFileAndReferenceAreEqual(file)
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
@@ -104,4 +106,18 @@ class HabitsCSVExporterTest : BaseUnitTest() {
|
||||
file.exists()
|
||||
)
|
||||
}
|
||||
|
||||
private fun assertFileAndReferenceAreEqual(s: String) {
|
||||
val assetFilename = String.format("csv_export/%s", s)
|
||||
val file = File.createTempFile("asset", "")
|
||||
file.deleteOnExit()
|
||||
copyAssetToFile(assetFilename, file)
|
||||
|
||||
assertTrue(
|
||||
FileUtils.contentEquals(
|
||||
file,
|
||||
File(String.format("%s/%s", baseDir.absolutePath, s))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user