fix JSONRPC tests
This commit is contained in:
parent
7e05d9be31
commit
6aeb18d674
@ -212,7 +212,7 @@ void TestJSONRPC::stateChangeEmitsNotifications()
|
|||||||
QNetworkReply *reply = nam.get(request);
|
QNetworkReply *reply = nam.get(request);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
|
|
||||||
// Make sure the notification contains all the stuff we expect
|
// Make sure the notification contains all the stuff we expect
|
||||||
QVariant stateChangedVariant = checkNotification(clientSpy, "Devices.StateChanged");
|
QVariant stateChangedVariant = checkNotification(clientSpy, "Devices.StateChanged");
|
||||||
@ -239,7 +239,7 @@ void TestJSONRPC::stateChangeEmitsNotifications()
|
|||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
// Lets wait a max of 100ms for the notification
|
// Lets wait a max of 100ms for the notification
|
||||||
clientSpy.wait(100);
|
clientSpy.wait();
|
||||||
// but make sure it doesn't come
|
// but make sure it doesn't come
|
||||||
QCOMPARE(clientSpy.count(), 0);
|
QCOMPARE(clientSpy.count(), 0);
|
||||||
|
|
||||||
@ -253,7 +253,6 @@ void TestJSONRPC::stateChangeEmitsNotifications()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TestJSONRPC::deviceAddedRemovedNotifications()
|
void TestJSONRPC::deviceAddedRemovedNotifications()
|
||||||
{
|
{
|
||||||
// enable notificartions
|
// enable notificartions
|
||||||
@ -273,7 +272,7 @@ void TestJSONRPC::deviceAddedRemovedNotifications()
|
|||||||
params.insert("deviceClassId", mockDeviceClassId);
|
params.insert("deviceClassId", mockDeviceClassId);
|
||||||
params.insert("deviceParams", deviceParams);
|
params.insert("deviceParams", deviceParams);
|
||||||
QVariant response = injectAndWait("Devices.AddConfiguredDevice", params);
|
QVariant response = injectAndWait("Devices.AddConfiguredDevice", params);
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
verifyDeviceError(response);
|
verifyDeviceError(response);
|
||||||
QVariantMap notificationDeviceMap = checkNotification(clientSpy, "Devices.DeviceAdded").toMap().value("params").toMap().value("device").toMap();
|
QVariantMap notificationDeviceMap = checkNotification(clientSpy, "Devices.DeviceAdded").toMap().value("params").toMap().value("device").toMap();
|
||||||
|
|
||||||
@ -293,7 +292,7 @@ void TestJSONRPC::deviceAddedRemovedNotifications()
|
|||||||
params.clear(); response.clear(); clientSpy.clear();
|
params.clear(); response.clear(); clientSpy.clear();
|
||||||
params.insert("deviceId", deviceId);
|
params.insert("deviceId", deviceId);
|
||||||
response = injectAndWait("Devices.RemoveConfiguredDevice", params);
|
response = injectAndWait("Devices.RemoveConfiguredDevice", params);
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
verifyDeviceError(response);
|
verifyDeviceError(response);
|
||||||
checkNotification(clientSpy, "Devices.DeviceRemoved");
|
checkNotification(clientSpy, "Devices.DeviceRemoved");
|
||||||
|
|
||||||
@ -338,7 +337,7 @@ void TestJSONRPC::ruleAddedRemovedNotifications()
|
|||||||
params.insert("stateEvaluator", stateEvaluator);
|
params.insert("stateEvaluator", stateEvaluator);
|
||||||
|
|
||||||
QVariant response = injectAndWait("Rules.AddRule", params);
|
QVariant response = injectAndWait("Rules.AddRule", params);
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
QVariantMap notificationRuleMap = checkNotification(clientSpy, "Rules.RuleAdded").toMap().value("params").toMap().value("rule").toMap();
|
QVariantMap notificationRuleMap = checkNotification(clientSpy, "Rules.RuleAdded").toMap().value("params").toMap().value("rule").toMap();
|
||||||
verifyRuleError(response);
|
verifyRuleError(response);
|
||||||
|
|
||||||
@ -358,7 +357,7 @@ void TestJSONRPC::ruleAddedRemovedNotifications()
|
|||||||
params.clear(); response.clear(); clientSpy.clear();
|
params.clear(); response.clear(); clientSpy.clear();
|
||||||
params.insert("ruleId", ruleId);
|
params.insert("ruleId", ruleId);
|
||||||
response = injectAndWait("Rules.RemoveRule", params);
|
response = injectAndWait("Rules.RemoveRule", params);
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
checkNotification(clientSpy, "Devices.DeviceRemoved");
|
checkNotification(clientSpy, "Devices.DeviceRemoved");
|
||||||
verifyRuleError(response);
|
verifyRuleError(response);
|
||||||
|
|
||||||
@ -399,7 +398,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
|
|||||||
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
|
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
|
||||||
|
|
||||||
response = injectAndWait("Rules.AddRule", params);
|
response = injectAndWait("Rules.AddRule", params);
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
QVariant notificationVariant = checkNotification(clientSpy, "Rules.RuleAdded");
|
QVariant notificationVariant = checkNotification(clientSpy, "Rules.RuleAdded");
|
||||||
verifyRuleError(response);
|
verifyRuleError(response);
|
||||||
|
|
||||||
@ -423,7 +422,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
|
|||||||
QNetworkReply *reply = nam.get(request);
|
QNetworkReply *reply = nam.get(request);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
notificationVariant = checkNotification(clientSpy, "Rules.RuleActiveChanged");
|
notificationVariant = checkNotification(clientSpy, "Rules.RuleActiveChanged");
|
||||||
verifyRuleError(response);
|
verifyRuleError(response);
|
||||||
|
|
||||||
@ -436,11 +435,11 @@ void TestJSONRPC::ruleActiveChangedNotifications()
|
|||||||
qDebug() << "setting mock int state to 42";
|
qDebug() << "setting mock int state to 42";
|
||||||
QNetworkRequest request2(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateId.toString()).arg(42)));
|
QNetworkRequest request2(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateId.toString()).arg(42)));
|
||||||
QNetworkReply *reply2 = nam.get(request2);
|
QNetworkReply *reply2 = nam.get(request2);
|
||||||
spy.wait(500);
|
spy.wait();
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
reply2->deleteLater();
|
reply2->deleteLater();
|
||||||
|
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
notificationVariant = checkNotification(clientSpy, "Rules.RuleActiveChanged");
|
notificationVariant = checkNotification(clientSpy, "Rules.RuleActiveChanged");
|
||||||
verifyRuleError(response);
|
verifyRuleError(response);
|
||||||
|
|
||||||
@ -452,7 +451,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
|
|||||||
params.insert("ruleId", ruleId);
|
params.insert("ruleId", ruleId);
|
||||||
response = injectAndWait("Rules.RemoveRule", params);
|
response = injectAndWait("Rules.RemoveRule", params);
|
||||||
|
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
notificationVariant = checkNotification(clientSpy, "Rules.RuleRemoved");
|
notificationVariant = checkNotification(clientSpy, "Rules.RuleRemoved");
|
||||||
checkNotification(clientSpy, "Logging.LogDatabaseUpdated");
|
checkNotification(clientSpy, "Logging.LogDatabaseUpdated");
|
||||||
verifyRuleError(response);
|
verifyRuleError(response);
|
||||||
@ -485,7 +484,7 @@ void TestJSONRPC::deviceParamsChangedNotifications()
|
|||||||
response = injectAndWait("Devices.AddConfiguredDevice", params);
|
response = injectAndWait("Devices.AddConfiguredDevice", params);
|
||||||
DeviceId deviceId = DeviceId(response.toMap().value("params").toMap().value("deviceId").toString());
|
DeviceId deviceId = DeviceId(response.toMap().value("params").toMap().value("deviceId").toString());
|
||||||
QVERIFY(!deviceId.isNull());
|
QVERIFY(!deviceId.isNull());
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
verifyDeviceError(response);
|
verifyDeviceError(response);
|
||||||
QVariantMap notificationDeviceMap = checkNotification(clientSpy, "Devices.DeviceAdded").toMap().value("params").toMap().value("device").toMap();
|
QVariantMap notificationDeviceMap = checkNotification(clientSpy, "Devices.DeviceAdded").toMap().value("params").toMap().value("device").toMap();
|
||||||
|
|
||||||
@ -509,7 +508,7 @@ void TestJSONRPC::deviceParamsChangedNotifications()
|
|||||||
params.insert("deviceId", deviceId);
|
params.insert("deviceId", deviceId);
|
||||||
params.insert("deviceParams", newDeviceParams);
|
params.insert("deviceParams", newDeviceParams);
|
||||||
response = injectAndWait("Devices.EditDevice", params);
|
response = injectAndWait("Devices.EditDevice", params);
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
verifyDeviceError(response);
|
verifyDeviceError(response);
|
||||||
QVariantMap editDeviceNotificationMap = checkNotification(clientSpy, "Devices.DeviceParamsChanged").toMap().value("params").toMap().value("device").toMap();
|
QVariantMap editDeviceNotificationMap = checkNotification(clientSpy, "Devices.DeviceParamsChanged").toMap().value("params").toMap().value("device").toMap();
|
||||||
QCOMPARE(editDeviceNotificationMap.value("deviceClassId").toString(), mockDeviceClassId.toString());
|
QCOMPARE(editDeviceNotificationMap.value("deviceClassId").toString(), mockDeviceClassId.toString());
|
||||||
@ -525,7 +524,7 @@ void TestJSONRPC::deviceParamsChangedNotifications()
|
|||||||
params.clear(); response.clear(); clientSpy.clear();
|
params.clear(); response.clear(); clientSpy.clear();
|
||||||
params.insert("deviceId", deviceId);
|
params.insert("deviceId", deviceId);
|
||||||
response = injectAndWait("Devices.RemoveConfiguredDevice", params);
|
response = injectAndWait("Devices.RemoveConfiguredDevice", params);
|
||||||
clientSpy.wait(500);
|
clientSpy.wait();
|
||||||
verifyDeviceError(response);
|
verifyDeviceError(response);
|
||||||
checkNotification(clientSpy, "Devices.DeviceRemoved");
|
checkNotification(clientSpy, "Devices.DeviceRemoved");
|
||||||
checkNotification(clientSpy, "Logging.LogDatabaseUpdated");
|
checkNotification(clientSpy, "Logging.LogDatabaseUpdated");
|
||||||
|
|||||||
Reference in New Issue
Block a user