La description publiée par l'introspection JSON-RPC annonçait « Only given properties will be set, others will be untouched. » C'est faux : unpack() construit un ChargingInfo NEUF depuis la charge utile, et setChargingInfo() remplace le stocké en entier. Un champ writable omis retombe donc sur son DÉFAUT — targetPercentage à 80, repeatDays vide, endDateTime absent, assignedCarId nul — et l'appel réussit, EnergyErrorNoError. Rien ne signale la perte. Constaté sur le banc .75 le 2026-08-26 en restaurant la configuration : un appel ne portant que chargingMode a porté targetPercentage de 0 à 80. C'est la DESCRIPTION qui est corrigée, pas le comportement, et le choix mérite d'être dit : ce .so est un drop-in de l'amont. Une sémantique de fusion casserait le seul geste qui permet d'EFFACER un champ — retirer une échéance, vider repeatDays — et changerait un contrat que les clients existants suivent déjà. La description énumère désormais chaque défaut et prescrit le geste correct : lire avec GetChargingInfos, modifier, renvoyer l'objet complet. Le test épingle le comportement annoncé, en trois temps : un objet complet, un appel partiel qui aboutit et perd les champs omis, puis l'aller-retour qui les préserve — y compris quand la charge utile relue porte chargingState, propriété en lecture seule que la méthode doit ignorer sans faillir. Il porte sur le COMPORTEMENT décrit, jamais sur la non-vacuité d'une réponse. Vérifié au passage : aucun autre Set* du namespace ne porte cette promesse ni ce comportement. SetPhasePowerLimit, SetAcquisitionTolerance, SetBatteryLevelConsideration et SetLockOnUnplug sont scalaires ; SetSpotMarketConfiguration ne remet jamais un champ omis à son défaut ; SetLoadConfig annonce déjà un remplacement d'ensemble. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TVywtayEeoRJ2yWUW4iZj
82 lines
2.5 KiB
C++
82 lines
2.5 KiB
C++
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
*
|
|
* Copyright (C) 2013 - 2024, nymea GmbH
|
|
* Copyright (C) 2024 - 2025, chargebyte austria GmbH
|
|
*
|
|
* This file is part of nymea-energy-plugin-nymea.
|
|
*
|
|
* nymea-energy-plugin-nymea.s free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* nymea-energy-plugin-nymea.s distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with nymea-energy-plugin-nymea. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
#include <QSignalSpy>
|
|
#include <QtTest>
|
|
|
|
#include "../common/energytestbase.h"
|
|
|
|
class TestCharging: public EnergyTestBase
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit TestCharging(QObject *parent = nullptr);
|
|
|
|
private slots:
|
|
// Basic adding and removing mock things
|
|
void testAddCharger();
|
|
void testAddSimpleCharger();
|
|
void testAddCar();
|
|
void testAddMeter();
|
|
|
|
// Basic api calls
|
|
void getSetPhaseLimits();
|
|
|
|
void getSetLockOnUnplug_data();
|
|
void getSetLockOnUnplug();
|
|
|
|
void getSetAcquisitionTolerance_data();
|
|
void getSetAcquisitionTolerance();
|
|
|
|
void getSetBatteryLevelConsideration_data();
|
|
void getSetBatteryLevelConsideration();
|
|
|
|
void addChargingInfo_data();
|
|
void addChargingInfo();
|
|
|
|
// [ETM] La description publiee de SetChargingInfo est un contrat : le test porte sur le
|
|
// COMPORTEMENT qu'elle annonce, pas sur la non-vacuite d'une reponse.
|
|
void setChargingInfoReplacesWholesale();
|
|
|
|
// Test individual logic
|
|
void testEcoMode_data();
|
|
void testEcoMode();
|
|
|
|
void testEcoModePhaseSwitching_data();
|
|
void testEcoModePhaseSwitching();
|
|
|
|
void testBatteryLevelConsideration_data();
|
|
void testBatteryLevelConsideration();
|
|
|
|
void batteryLevelConsiderationStopCharging_data();
|
|
void batteryLevelConsiderationStopCharging();
|
|
|
|
void testOverloadProtectionManualMode_data();
|
|
void testOverloadProtectionManualMode();
|
|
|
|
void testOverloadProtectionEcoMode_data();
|
|
void testOverloadProtectionEcoMode();
|
|
|
|
};
|