Skip to content

Commit

Permalink
simplify DaysServiceTest
Browse files Browse the repository at this point in the history
  • Loading branch information
mvmike committed Jan 12, 2024
1 parent 1d4ede7 commit 871d540
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 385 deletions.
20 changes: 20 additions & 0 deletions app/src/test/kotlin/cat/mvmike/minimalcalendarwidget/BaseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ import io.mockk.mockk
import io.mockk.mockkObject
import io.mockk.unmockkAll
import io.mockk.verify
import org.assertj.core.api.Assertions.fail
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.TestInstance
import java.io.File
import java.io.FileInputStream
import java.io.InputStreamReader
import java.nio.charset.StandardCharsets
import java.time.DayOfWeek
import java.time.Instant
import java.time.LocalDate
Expand Down Expand Up @@ -414,4 +419,19 @@ open class BaseTest {
intent.getLongExtra("startOfDayInEpochSeconds", systemInstant.epochSecond)
} returns extraInstant.epochSecond
}

// UTILS

internal fun readTestResourceCsvFile(path: String) =
InputStreamReader(
FileInputStream(
File(
this::class.java.getResource(path)?.toURI()
?: fail("could not load $path")
)
),
StandardCharsets.UTF_8
).readLines()
.drop(1) // header
.map { it.split(',', ignoreCase = false).toTypedArray() }
}

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions app/src/test/resources/system_all_day_instances.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#isDeclined,start,end
false,2018-11-26,2018-11-26
false,2018-12-03,2018-12-03
false,2018-12-04,2018-12-04
false,2018-12-06,2018-12-06
false,2018-12-06,2018-12-06
false,2018-12-10,2018-12-10
false,2018-12-10,2018-12-10
false,2018-12-10,2018-12-10
true,2018-12-18,2018-12-18
false,2018-12-27,2018-12-27
false,2018-12-30,2018-12-30
false,2018-12-30,2018-12-30
false,2018-12-30,2018-12-30
true,2018-12-30,2018-12-30
true,2018-12-30,2018-12-30
false,2019-01-05,2019-01-05
false,2019-01-05,2019-01-05
true,2019-01-05,2019-01-05
false,2019-01-05,2019-01-05
false,2019-01-05,2019-01-05
false,2019-01-05,2019-01-05
6 changes: 6 additions & 0 deletions app/src/test/resources/system_timed_instances.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#isDeclined,start,end
false,2018-11-28T00:00:00+03:00,2018-11-29T09:00:00+03:00
false,2018-12-06T02:00:00+03:00,2018-12-07T04:00:00+03:00
false,2018-12-10T12:00:00+03:00,2018-12-11T13:00:00+03:00
false,2019-01-01T05:00:00+03:00,2019-10-02T11:20:00+03:00
false,2019-01-02T05:00:00+03:00,2019-08-02T11:20:00+03:00
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#dayOfMonth,instancesSymbol,dayOfWeek,startOfDayInEpochSecond,isInMonth,isToday,highlightDrawable,alignment
26,·,MONDAY,1543179600,false,false,,ALIGN_OPPOSITE
27, ,TUESDAY,1543266000,false,false,,ALIGN_OPPOSITE
28,·,WEDNESDAY,1543352400,false,false,,ALIGN_OPPOSITE
29,·,THURSDAY,1543438800,false,false,,ALIGN_OPPOSITE
30, ,FRIDAY,1543525200,false,false,,ALIGN_OPPOSITE
1, ,SATURDAY,1543611600,true,false,,ALIGN_OPPOSITE
2, ,SUNDAY,1543698000,true,false,,ALIGN_OPPOSITE
3,·,MONDAY,1543784400,true,false,,ALIGN_OPPOSITE
4,·,TUESDAY,1543870800,true,true,2131165277,ALIGN_OPPOSITE
5, ,WEDNESDAY,1543957200,true,false,,ALIGN_OPPOSITE
6,∴,THURSDAY,1544043600,true,false,,ALIGN_OPPOSITE
7,·,FRIDAY,1544130000,true,false,,ALIGN_OPPOSITE
8, ,SATURDAY,1544216400,true,false,,ALIGN_OPPOSITE
9, ,SUNDAY,1544302800,true,false,,ALIGN_OPPOSITE
10,∷,MONDAY,1544389200,true,false,,ALIGN_OPPOSITE
11,·,TUESDAY,1544475600,true,false,,ALIGN_OPPOSITE
12, ,WEDNESDAY,1544562000,true,false,,ALIGN_OPPOSITE
13, ,THURSDAY,1544648400,true,false,,ALIGN_OPPOSITE
14, ,FRIDAY,1544734800,true,false,,ALIGN_OPPOSITE
15, ,SATURDAY,1544821200,true,false,,ALIGN_OPPOSITE
16, ,SUNDAY,1544907600,true,false,,ALIGN_OPPOSITE
17, ,MONDAY,1544994000,true,false,,ALIGN_OPPOSITE
18, ,TUESDAY,1545080400,true,false,,ALIGN_OPPOSITE
19, ,WEDNESDAY,1545166800,true,false,,ALIGN_OPPOSITE
20, ,THURSDAY,1545253200,true,false,,ALIGN_OPPOSITE
21, ,FRIDAY,1545339600,true,false,,ALIGN_OPPOSITE
22, ,SATURDAY,1545426000,true,false,,ALIGN_OPPOSITE
23, ,SUNDAY,1545512400,true,false,,ALIGN_OPPOSITE
24, ,MONDAY,1545598800,true,false,,ALIGN_OPPOSITE
25, ,TUESDAY,1545685200,true,false,,ALIGN_OPPOSITE
26, ,WEDNESDAY,1545771600,true,false,,ALIGN_OPPOSITE
27,·,THURSDAY,1545858000,true,false,,ALIGN_OPPOSITE
28, ,FRIDAY,1545944400,true,false,,ALIGN_OPPOSITE
29, ,SATURDAY,1546030800,true,false,,ALIGN_OPPOSITE
30,∴,SUNDAY,1546117200,true,false,,ALIGN_OPPOSITE
31, ,MONDAY,1546203600,true,false,,ALIGN_OPPOSITE
1,·,TUESDAY,1546290000,false,false,,ALIGN_OPPOSITE
2,∶,WEDNESDAY,1546376400,false,false,,ALIGN_OPPOSITE
3,∶,THURSDAY,1546462800,false,false,,ALIGN_OPPOSITE
4,∶,FRIDAY,1546549200,false,false,,ALIGN_OPPOSITE
5,◈,SATURDAY,1546635600,false,false,,ALIGN_OPPOSITE
6,∶,SUNDAY,1546722000,false,false,,ALIGN_OPPOSITE
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#dayOfMonth,instancesSymbol,dayOfWeek,startOfDayInEpochSecond,isInMonth,isToday,highlightDrawable,alignment
25, ,MONDAY,1574629200,false,false,,
26, ,TUESDAY,1574715600,false,false,,
27, ,WEDNESDAY,1574802000,false,false,,
28, ,THURSDAY,1574888400,false,false,,
29, ,FRIDAY,1574974800,false,false,,
30, ,SATURDAY,1575061200,false,false,,
1, ,SUNDAY,1575147600,true,false,,
2, ,MONDAY,1575234000,true,false,,
3, ,TUESDAY,1575320400,true,false,,
4, ,WEDNESDAY,1575406800,true,true,2131165273,
5, ,THURSDAY,1575493200,true,false,,
6, ,FRIDAY,1575579600,true,false,,
7, ,SATURDAY,1575666000,true,false,,
8, ,SUNDAY,1575752400,true,false,,
9, ,MONDAY,1575838800,true,false,,
10, ,TUESDAY,1575925200,true,false,,
11, ,WEDNESDAY,1576011600,true,false,,
12, ,THURSDAY,1576098000,true,false,,
13, ,FRIDAY,1576184400,true,false,,
14, ,SATURDAY,1576270800,true,false,,
15, ,SUNDAY,1576357200,true,false,,
16, ,MONDAY,1576443600,true,false,,
17, ,TUESDAY,1576530000,true,false,,
18, ,WEDNESDAY,1576616400,true,false,,
19, ,THURSDAY,1576702800,true,false,,
20, ,FRIDAY,1576789200,true,false,,
21, ,SATURDAY,1576875600,true,false,,
22, ,SUNDAY,1576962000,true,false,,
23, ,MONDAY,1577048400,true,false,,
24, ,TUESDAY,1577134800,true,false,,
25, ,WEDNESDAY,1577221200,true,false,,
26, ,THURSDAY,1577307600,true,false,,
27, ,FRIDAY,1577394000,true,false,,
28, ,SATURDAY,1577480400,true,false,,
29, ,SUNDAY,1577566800,true,false,,
30, ,MONDAY,1577653200,true,false,,
31, ,TUESDAY,1577739600,true,false,,
1, ,WEDNESDAY,1577826000,false,false,,
2, ,THURSDAY,1577912400,false,false,,
3, ,FRIDAY,1577998800,false,false,,
4, ,SATURDAY,1578085200,false,false,,
5, ,SUNDAY,1578171600,false,false,,
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#dayOfMonth,instancesSymbol,dayOfWeek,startOfDayInEpochSecond,isInMonth,isToday,highlightDrawable,alignment
25, ,SUNDAY,1543093200,false,false,,ALIGN_OPPOSITE
26,☱,MONDAY,1543179600,false,false,,ALIGN_OPPOSITE
27, ,TUESDAY,1543266000,false,false,,ALIGN_OPPOSITE
28,☱,WEDNESDAY,1543352400,false,false,,ALIGN_OPPOSITE
29,☱,THURSDAY,1543438800,false,false,,ALIGN_OPPOSITE
30, ,FRIDAY,1543525200,false,false,,ALIGN_OPPOSITE
1, ,SATURDAY,1543611600,true,false,,ALIGN_OPPOSITE
2, ,SUNDAY,1543698000,true,false,,ALIGN_OPPOSITE
3,☱,MONDAY,1543784400,true,false,,ALIGN_OPPOSITE
4,☱,TUESDAY,1543870800,true,true,2131165278,ALIGN_OPPOSITE
5, ,WEDNESDAY,1543957200,true,false,,ALIGN_OPPOSITE
6,☳,THURSDAY,1544043600,true,false,,ALIGN_OPPOSITE
7,☱,FRIDAY,1544130000,true,false,,ALIGN_OPPOSITE
8, ,SATURDAY,1544216400,true,false,,ALIGN_OPPOSITE
9, ,SUNDAY,1544302800,true,false,,ALIGN_OPPOSITE
10,☴,MONDAY,1544389200,true,false,,ALIGN_OPPOSITE
11,☱,TUESDAY,1544475600,true,false,,ALIGN_OPPOSITE
12, ,WEDNESDAY,1544562000,true,false,,ALIGN_OPPOSITE
13, ,THURSDAY,1544648400,true,false,,ALIGN_OPPOSITE
14, ,FRIDAY,1544734800,true,false,,ALIGN_OPPOSITE
15, ,SATURDAY,1544821200,true,false,,ALIGN_OPPOSITE
16, ,SUNDAY,1544907600,true,false,,ALIGN_OPPOSITE
17, ,MONDAY,1544994000,true,false,,ALIGN_OPPOSITE
18, ,TUESDAY,1545080400,true,false,,ALIGN_OPPOSITE
19, ,WEDNESDAY,1545166800,true,false,,ALIGN_OPPOSITE
20, ,THURSDAY,1545253200,true,false,,ALIGN_OPPOSITE
21, ,FRIDAY,1545339600,true,false,,ALIGN_OPPOSITE
22, ,SATURDAY,1545426000,true,false,,ALIGN_OPPOSITE
23, ,SUNDAY,1545512400,true,false,,ALIGN_OPPOSITE
24, ,MONDAY,1545598800,true,false,,ALIGN_OPPOSITE
25, ,TUESDAY,1545685200,true,false,,ALIGN_OPPOSITE
26, ,WEDNESDAY,1545771600,true,false,,ALIGN_OPPOSITE
27,☱,THURSDAY,1545858000,true,false,,ALIGN_OPPOSITE
28, ,FRIDAY,1545944400,true,false,,ALIGN_OPPOSITE
29, ,SATURDAY,1546030800,true,false,,ALIGN_OPPOSITE
30,☳,SUNDAY,1546117200,true,false,,ALIGN_OPPOSITE
31, ,MONDAY,1546203600,true,false,,ALIGN_OPPOSITE
1,☱,TUESDAY,1546290000,false,false,,ALIGN_OPPOSITE
2,☲,WEDNESDAY,1546376400,false,false,,ALIGN_OPPOSITE
3,☲,THURSDAY,1546462800,false,false,,ALIGN_OPPOSITE
4,☲,FRIDAY,1546549200,false,false,,ALIGN_OPPOSITE
5,☷,SATURDAY,1546635600,false,false,,ALIGN_OPPOSITE
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#dayOfMonth,instancesSymbol,dayOfWeek,startOfDayInEpochSecond,isInMonth,isToday,highlightDrawable,alignment
22, ,THURSDAY,1542834000,false,false,,
23, ,FRIDAY,1542920400,false,false,,
24, ,SATURDAY,1543006800,false,false,,
25, ,SUNDAY,1543093200,false,false,,
26, ,MONDAY,1543179600,false,false,,
27, ,TUESDAY,1543266000,false,false,,
28, ,WEDNESDAY,1543352400,false,false,,
29, ,THURSDAY,1543438800,false,false,,
30, ,FRIDAY,1543525200,false,false,,
1, ,SATURDAY,1543611600,true,false,,
2, ,SUNDAY,1543698000,true,false,,
3, ,MONDAY,1543784400,true,false,,
4, ,TUESDAY,1543870800,true,true,2131165273,
5, ,WEDNESDAY,1543957200,true,false,,
6, ,THURSDAY,1544043600,true,false,,
7, ,FRIDAY,1544130000,true,false,,
8, ,SATURDAY,1544216400,true,false,,
9, ,SUNDAY,1544302800,true,false,,
10, ,MONDAY,1544389200,true,false,,
11, ,TUESDAY,1544475600,true,false,,
12, ,WEDNESDAY,1544562000,true,false,,
13, ,THURSDAY,1544648400,true,false,,
14, ,FRIDAY,1544734800,true,false,,
15, ,SATURDAY,1544821200,true,false,,
16, ,SUNDAY,1544907600,true,false,,
17, ,MONDAY,1544994000,true,false,,
18, ,TUESDAY,1545080400,true,false,,
19, ,WEDNESDAY,1545166800,true,false,,
20, ,THURSDAY,1545253200,true,false,,
21, ,FRIDAY,1545339600,true,false,,
22, ,SATURDAY,1545426000,true,false,,
23, ,SUNDAY,1545512400,true,false,,
24, ,MONDAY,1545598800,true,false,,
25, ,TUESDAY,1545685200,true,false,,
26, ,WEDNESDAY,1545771600,true,false,,
27, ,THURSDAY,1545858000,true,false,,
28, ,FRIDAY,1545944400,true,false,,
29, ,SATURDAY,1546030800,true,false,,
30, ,SUNDAY,1546117200,true,false,,
31, ,MONDAY,1546203600,true,false,,
1, ,TUESDAY,1546290000,false,false,,
2, ,WEDNESDAY,1546376400,false,false,,

0 comments on commit 871d540

Please sign in to comment.