Skip to content

Commit

Permalink
#10471 mock Datetime.now on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloo committed Jul 11, 2024
1 parent 4077b43 commit dbf5aaa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/devices/get_system_date_and_time_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,25 @@ defmodule Onvif.Devices.GetSystemDateAndTimeTest do
{:ok, %{status: 200, body: xml_response}}
end)

Mimic.expect(DateTime, :utc_now, fn ->
~U[2024-07-09 20:00:00.227234Z]
end)

{:ok, service_capabilities} = Onvif.Devices.GetSystemDateAndTime.request(device)

assert service_capabilities == %Onvif.Devices.SystemDateAndTime{
current_diff: -151435,
current_diff: -654,
date_time_type: :manual,
datetime: ~U[2024-07-09 19:49:06Z],
daylight_savings: true,
local_date_time: %Onvif.Devices.SystemDateAndTime.UTCDateTime{
date: %Onvif.Devices.SystemDateAndTime.UTCDateTime.Date{
local_date_time: %Onvif.Devices.SystemDateAndTime.LocalDateTime{
date: %Onvif.Devices.SystemDateAndTime.LocalDateTime.Date{
day: 9,
month: 7,
year: 2024
},
time: %Onvif.Devices.SystemDateAndTime.UTCDateTime.Time{
hour: 19,
time: %Onvif.Devices.SystemDateAndTime.LocalDateTime.Time{
hour: 16,
minute: 49,
second: 6
}
Expand All @@ -42,7 +46,7 @@ defmodule Onvif.Devices.GetSystemDateAndTimeTest do
year: 2024
},
time: %Onvif.Devices.SystemDateAndTime.UTCDateTime.Time{
hour: 16,
hour: 19,
minute: 49,
second: 6
}
Expand Down
1 change: 1 addition & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ExUnit.start()

Mimic.copy(Tesla)
Mimic.copy(DateTime)

0 comments on commit dbf5aaa

Please sign in to comment.