Test CSV export file content

pull/1177/head
Quentin Hibon 4 years ago
parent b27f3f8540
commit 7776093217

@ -0,0 +1 @@
2015-01-25,0.0000
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
1 2015-01-25 2
2 2015-01-24 0
3 2015-01-23 1
4 2015-01-22 2
5 2015-01-21 2
6 2015-01-20 2
7 2015-01-19 1
8 2015-01-18 1
9 2015-01-17 2
10 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
1 2015-01-25 0.2557
2 2015-01-24 0.2226
3 2015-01-23 0.1991
4 2015-01-22 0.1746
5 2015-01-21 0.1379
6 2015-01-20 0.0995
7 2015-01-19 0.0706
8 2015-01-18 0.0515
9 2015-01-17 0.0315
10 2015-01-16 0.0107

@ -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,
1 Date Meditate Wake up early
2 2015-01-25 -1 2
3 2015-01-24 -1 0
4 2015-01-23 -1 1
5 2015-01-22 -1 2
6 2015-01-21 -1 2
7 2015-01-20 -1 2
8 2015-01-19 -1 1
9 2015-01-18 -1 1
10 2015-01-17 -1 2
11 2015-01-16 -1 2

@ -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
1 Position Name Question Description NumRepetitions Interval Color
2 001 Meditate Did you meditate this morning? 1 1 #FF8F00
3 002 Wake up early Did you wake up before 6am? 2 3 #00897B

@ -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,
1 Date Meditate Wake up early
2 2015-01-25 0.0000 0.2557
3 2015-01-24 0.0000 0.2226
4 2015-01-23 0.0000 0.1991
5 2015-01-22 0.0000 0.1746
6 2015-01-21 0.0000 0.1379
7 2015-01-20 0.0000 0.0995
8 2015-01-19 0.0000 0.0706
9 2015-01-18 0.0000 0.0515
10 2015-01-17 0.0000 0.0315
11 2015-01-16 0.0000 0.0107

@ -34,6 +34,7 @@ import java.util.zip.ZipFile
class HabitsCSVExporterTest : BaseUnitTest() { class HabitsCSVExporterTest : BaseUnitTest() {
private lateinit var baseDir: File private lateinit var baseDir: File
@Before @Before
@Throws(Exception::class) @Throws(Exception::class)
override fun setUp() { override fun setUp() {
@ -41,12 +42,7 @@ class HabitsCSVExporterTest : BaseUnitTest() {
habitList.add(fixtures.createShortHabit()) habitList.add(fixtures.createShortHabit())
habitList.add(fixtures.createEmptyHabit()) habitList.add(fixtures.createEmptyHabit())
baseDir = Files.createTempDirectory("csv").toFile() baseDir = Files.createTempDirectory("csv").toFile()
} baseDir.deleteOnExit()
@Throws(Exception::class)
override fun tearDown() {
FileUtils.deleteDirectory(baseDir)
super.tearDown()
} }
@Test @Test
@ -63,14 +59,20 @@ class HabitsCSVExporterTest : BaseUnitTest() {
assertAbsolutePathExists(filename) assertAbsolutePathExists(filename)
val archive = File(filename) val archive = File(filename)
unzip(archive) unzip(archive)
assertPathExists("Habits.csv") val filesToCheck = arrayOf(
assertPathExists("001 Meditate/Checkmarks.csv") "001 Meditate/Checkmarks.csv",
assertPathExists("001 Meditate/Scores.csv") "001 Meditate/Scores.csv",
assertPathExists("002 Wake up early") "002 Wake up early/Checkmarks.csv",
assertPathExists("002 Wake up early/Checkmarks.csv") "002 Wake up early/Scores.csv",
assertPathExists("002 Wake up early/Scores.csv") "Checkmarks.csv",
assertPathExists("Checkmarks.csv") "Habits.csv",
assertPathExists("Scores.csv") "Scores.csv"
)
for (file in filesToCheck) {
assertPathExists(file)
assertFileAndReferenceAreEqual(file)
}
} }
@Throws(IOException::class) @Throws(IOException::class)
@ -104,4 +106,18 @@ class HabitsCSVExporterTest : BaseUnitTest() {
file.exists() 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))
)
)
}
} }

Loading…
Cancel
Save