def test_iot_digitaltwin_monitor_events_error(self, fixture_cmd,
                                               serviceclienterror,
                                               interface, timeout):
     with pytest.raises(CLIError):
         subject.iot_digitaltwin_monitor_events(fixture_cmd,
                                                device_id=device_id,
                                                source_model='public',
                                                interface=interface,
                                                timeout=timeout,
                                                yes=True,
                                                properties='all',
                                                login=mock_target['cs'])
    def test_iot_digitaltwin_monitor_events(self, fixture_cmd, serviceclient):
        subject.iot_digitaltwin_monitor_events(fixture_cmd,
                                               device_id=device_id,
                                               interface='environmentalSensor',
                                               source_model='public',
                                               yes=True,
                                               properties='all',
                                               login=mock_target['cs'])
        args = serviceclient.call_args
        url = args[0][0].url
        method = args[0][0].method

        assert method == 'GET'
        assert '/models/' in url
Example #3
0
    def test_iot_digitaltwin_monitor_events_entrypoint(
        self, fixture_cmd, fixture_monitor_events_entrypoint, req
    ):
        subject.iot_digitaltwin_monitor_events(
            fixture_cmd,
            device_id=req["device_id"],
            device_query=req["device_query"],
            interface=req["interface_name"],
            consumer_group=req["consumer_group"],
            content_type=req["content_type"],
            enqueued_time=req["enqueued_time"],
            timeout=req["timeout"],
            hub_name=req["hub_name"],
            resource_group_name=req["resource_group_name"],
            yes=req["yes"],
            properties=req["properties"],
            repair=req["repair"],
            login=req["login"],
        )

        monitor_events_args = fixture_monitor_events_entrypoint.call_args[1]

        assert monitor_events_args["pnp_context"]

        dt_attribute_set = [
            "device_id",
            "device_query",
            "interface_name",
            "consumer_group",
            "enqueued_time",
            "content_type",
            "timeout",
            "login",
            "hub_name",
            "resource_group_name",
            "yes",
            "properties",
            "repair",
        ]
        for attribute in dt_attribute_set:
            if req[attribute]:
                assert monitor_events_args[attribute] == req[attribute]
            else:
                assert not monitor_events_args[attribute]