pub struct Fixture { /* private fields */ }Expand description
A device as recorded in a fixture directory:
tr64desc.xml
scpd/<file>.xml
responses/<service>/<action>[@<index>].json
lists/<name>.<xml|json>
api/<path>.json
data/<page>.json
homeauto/<ain>.xmlA list document lists/devicehostlist.xml is served at the path
/devicehostlist.lua that an action like X_AVM-DE_GetHostListPath
returns. A document api/v0/smarthome/overview.json of the REST API is
served at /api/v0/smarthome/overview. A page data/ecoStat.json of the
web interface answers a form with page=ecoStat posted to /data.lua.
The statistics homeauto/116300000001.xml answer the command
getbasicdevicestats of the Smart Home HTTP interface for the device
11630 0000001.
Implementations§
Source§impl Fixture
impl Fixture
Sourcepub fn bundled(name: &str) -> Result<Self, Error>
pub fn bundled(name: &str) -> Result<Self, Error>
Loads a fixture that comes with this crate, by name like
fritzbox-7690/8.25. The fixtures are part of the crate, so this
reads no files. See Fixture::bundled_names.
§Errors
Error::Unknown if no fixture has the name.
Sourcepub fn bundled_names() -> Vec<String>
pub fn bundled_names() -> Vec<String>
The names of the fixtures that come with this crate, sorted, like
fritzbox-7690/8.25. Tests can run against each of them.
Sourcepub fn load(dir: impl AsRef<Path>) -> Result<Self, Error>
pub fn load(dir: impl AsRef<Path>) -> Result<Self, Error>
Loads the fixture in dir.
§Errors
The errors of reading the files, and Error::Invalid if one of
them cannot be parsed.
Sourcepub fn description(&self) -> &DeviceDescription
pub fn description(&self) -> &DeviceDescription
The device description.
Sourcepub fn answer(
&self,
service: &str,
action: &str,
index: Option<u32>,
) -> Option<&Answer>
pub fn answer( &self, service: &str, action: &str, index: Option<u32>, ) -> Option<&Answer>
The recorded answer to a call of action of the service service,
like Hosts1, with the given index or without one.
Sourcepub fn with_answer(
self,
service: &str,
action: &str,
index: Option<u32>,
answer: Answer,
) -> Self
pub fn with_answer( self, service: &str, action: &str, index: Option<u32>, answer: Answer, ) -> Self
Records answer for calls of action of the service service,
like Hosts1, with the given index or without one, in place of a
recorded answer. For tests of answers the fixture lacks.