def test_interface_create(self, fixture_cmd, serviceclient, payload_scenario): payload = None # If file path provided if not payload_scenario[0]: payload = payload_scenario[1] else: payload = str( read_file_content(_pnp_create_interface_payload_file)) subject.iot_pnp_interface_create(fixture_cmd, interface_definition=payload, login=mock_target["cs"]) args = serviceclient.call_args url = args[0][0].url method = args[0][0].method data = args[0][0].data headers = args[0][0].headers assert method == "PUT" assert ("{}/models/{}?".format( _repo_endpoint, url_encode_str(_pnp_generic_interface_id, plus=True)) in url) assert "repositoryId={}".format(_repo_id) in url assert json.dumps(data) assert headers.get("Authorization")
def test_interface_create_error(self, fixture_cmd, serviceclient_generic_error, payload_scenario): with pytest.raises(CLIError): subject.iot_pnp_interface_create( fixture_cmd, login=mock_target['cs'], interface_definition=payload_scenario[0])
def test_interface_create_invalid_payload(self, serviceclient): payload = str(read_file_content(_pnp_create_interface_payload_file)) payload = json.loads(payload) del payload["@id"] payload = json.dumps(payload) with pytest.raises(CLIError): subject.iot_pnp_interface_create(fixture_cmd, login=mock_target["cs"], interface_definition=payload)
def test_interface_create_invalid_args(self, serviceclient, payload_scenario, exp): with pytest.raises(exp): subject.iot_pnp_interface_create( fixture_cmd, interface_definition=payload_scenario)