Skip to content

Commit

Permalink
#10471 add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloo committed Jul 11, 2024
1 parent 117db60 commit 9d96e88
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/devices/fixture/get_system_date_and_time.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:acert="http://www.axis.com/vapix/ws/cert" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:aa="http://www.axis.com/vapix/ws/action1" xmlns:acertificates="http://www.axis.com/vapix/ws/certificates" xmlns:aentry="http://www.axis.com/vapix/ws/entry" xmlns:aev="http://www.axis.com/vapix/ws/event1" xmlns:aeva="http://www.axis.com/vapix/ws/embeddedvideoanalytics1" xmlns:ali1="http://www.axis.com/vapix/ws/light/CommonBinding" xmlns:ali2="http://www.axis.com/vapix/ws/light/IntensityBinding" xmlns:ali3="http://www.axis.com/vapix/ws/light/AngleOfIlluminationBinding" xmlns:ali4="http://www.axis.com/vapix/ws/light/DayNightSynchronizeBinding" xmlns:ali="http://www.axis.com/vapix/ws/light" xmlns:apc="http://www.axis.com/vapix/ws/panopsiscalibration1" xmlns:arth="http://www.axis.com/vapix/ws/recordedtour1" xmlns:asd="http://www.axis.com/vapix/ws/shockdetection" xmlns:aweb="http://www.axis.com/vapix/ws/webserver" xmlns:tan1="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding" xmlns:tan2="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev1="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:tev2="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:tev3="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tev4="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tr2="http://www.onvif.org/ver20/media/wsdl" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
<SOAP-ENV:Body>
<tds:GetSystemDateAndTimeResponse>
<tds:SystemDateAndTime>
<tt:DateTimeType>Manual</tt:DateTimeType>
<tt:DaylightSavings>true</tt:DaylightSavings>
<tt:TimeZone>
<tt:TZ>BRT3</tt:TZ>
</tt:TimeZone>
<tt:UTCDateTime>
<tt:Time>
<tt:Hour>19</tt:Hour>
<tt:Minute>49</tt:Minute>
<tt:Second>6</tt:Second>
</tt:Time>
<tt:Date>
<tt:Year>2024</tt:Year>
<tt:Month>7</tt:Month>
<tt:Day>9</tt:Day>
</tt:Date>
</tt:UTCDateTime>
<tt:LocalDateTime>
<tt:Time>
<tt:Hour>16</tt:Hour>
<tt:Minute>49</tt:Minute>
<tt:Second>6</tt:Second>
</tt:Time>
<tt:Date>
<tt:Year>2024</tt:Year>
<tt:Month>7</tt:Month>
<tt:Day>9</tt:Day>
</tt:Date>
</tt:LocalDateTime>
</tds:SystemDateAndTime>
</tds:GetSystemDateAndTimeResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
54 changes: 54 additions & 0 deletions test/devices/get_system_date_and_time_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
defmodule Onvif.Devices.GetSystemDateAndTimeTest do
use ExUnit.Case, async: true

@moduletag capture_log: true

describe "GetSystemDateAndTime/1" do
test "should parse with correct values" do
xml_response = File.read!("test/devices/fixtures/get_system_date_and_time.xml")

device = Onvif.Factory.device()

Mimic.expect(Tesla, :request, fn _client, _opts ->
{:ok, %{status: 200, body: xml_response}}
end)

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

assert service_capabilities == Onvif.Devices.SystemDateAndTime{
current_diff: -572,
date_time_type: :manual,
datetime: ~U[2024-07-09 16:49:06Z],
daylight_savings: true,
local_date_time: %Onvif.Devices.SystemDateAndTime.UTCDateTime{
date: %Onvif.Devices.SystemDateAndTime.UTCDateTime.Date{
day: 9,
month: 7,
year: 2024
},
time: %Onvif.Devices.SystemDateAndTime.UTCDateTime.Time{
hour: 19,
minute: 49,
second: 06
}
},
time_zone: %Onvif.Devices.SystemDateAndTime.TimeZone{
tz: "BRT3BRST,M3.2.0/2,M11.1.0/2"
},
utc_date_time: %Onvif.Devices.SystemDateAndTime.UTCDateTime{
date: %Onvif.Devices.SystemDateAndTime.UTCDateTime.Date{
day: 9,
month: 7,
year: 2024
},
time: %Onvif.Devices.SystemDateAndTime.UTCDateTime.Time{
hour: 16,
minute: 49,
second: 06
}
}
}
end
end

end

0 comments on commit 9d96e88

Please sign in to comment.