Set test timezone

pull/2206/head
Alex Baker 2 years ago
parent 91da3191c5
commit 049e4a9329

@ -5,7 +5,8 @@ import org.tasks.data.CaldavTask
import org.tasks.data.TagData
import org.tasks.time.DateTime
import java.text.SimpleDateFormat
import java.util.*
import java.util.Locale
import java.util.TimeZone
object MicrosoftConverter {
@ -26,7 +27,7 @@ object MicrosoftConverter {
completionDate = remote.completedDateTime
?.let {
val tz = TimeZone.getTimeZone(it.timeZone)
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.ssssss")
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.ssssss", Locale.US)
.apply { timeZone = tz }
.parse(it.dateTime)
?.time

@ -3,8 +3,10 @@ package org.tasks.sync.microsoft
import com.natpryce.makeiteasy.MakeItEasy
import com.todoroo.astrid.data.Task
import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Test
import org.tasks.TestUtilities
import org.tasks.TestUtilities.withTZ
import org.tasks.makers.TaskMaker
import org.tasks.time.DateTime
@ -12,7 +14,7 @@ class ConvertFromMicrosoftTests {
@Test
fun titleFromRemote() {
val (local, _) = TestUtilities.mstodo("microsoft/basic_task.txt")
Assert.assertEquals("Basic task", local.title)
assertEquals("Basic task", local.title)
}
@Test
@ -28,7 +30,7 @@ class ConvertFromMicrosoftTests {
task = TaskMaker.newTask(MakeItEasy.with(TaskMaker.PRIORITY, Task.Priority.MEDIUM)),
defaultPriority = Task.Priority.LOW
)
Assert.assertEquals(Task.Priority.MEDIUM, local.priority)
assertEquals(Task.Priority.MEDIUM, local.priority)
}
@Test
@ -38,7 +40,7 @@ class ConvertFromMicrosoftTests {
task = TaskMaker.newTask(MakeItEasy.with(TaskMaker.PRIORITY, Task.Priority.HIGH)),
defaultPriority = Task.Priority.LOW
)
Assert.assertEquals(Task.Priority.LOW, local.priority)
assertEquals(Task.Priority.LOW, local.priority)
}
@Test
@ -48,18 +50,20 @@ class ConvertFromMicrosoftTests {
task = TaskMaker.newTask(MakeItEasy.with(TaskMaker.PRIORITY, Task.Priority.HIGH)),
defaultPriority = Task.Priority.HIGH
)
Assert.assertEquals(Task.Priority.NONE, local.priority)
assertEquals(Task.Priority.NONE, local.priority)
}
@Test
fun noCompletionDate() {
val (local, _) = TestUtilities.mstodo("microsoft/basic_task.txt")
Assert.assertEquals(0, local.completionDate)
assertEquals(0, local.completionDate)
}
@Test
fun parseCompletionDate() {
val (local, _) = TestUtilities.mstodo("microsoft/completed_task.txt")
Assert.assertEquals(DateTime(2022, 9, 18, 0, 0).millis, local.completionDate)
withTZ("America/Chicago") {
assertEquals(DateTime(2022, 9, 18, 0, 0).millis, local.completionDate)
}
}
}
Loading…
Cancel
Save