From 3b639cb0e1c27bf6fe06fe6b9e15490fbb47af50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 11 Mar 2016 10:48:25 +0100 Subject: [PATCH] prepare remove policy tests --- tests/auto/restlogging/testrestlogging.cpp | 8 ----- tests/auto/rules/testrules.cpp | 41 +++++++++++++++++++++- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/tests/auto/restlogging/testrestlogging.cpp b/tests/auto/restlogging/testrestlogging.cpp index 7bd8648c..0758281b 100644 --- a/tests/auto/restlogging/testrestlogging.cpp +++ b/tests/auto/restlogging/testrestlogging.cpp @@ -202,14 +202,6 @@ void TestRestLogging::eventLogs() QVERIFY2(found, "Could not find the corresponding Logging.LogEntryAdded notification"); - -// // Make sure the notification contains all the stuff we expect -// QCOMPARE(logEntry.value("typeId").toString(), mockEvent1Id.toString()); -// QCOMPARE(logEntry.value("deviceId").toString(), device->id().toString()); -// QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger)); -// QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceEvents)); -// QCOMPARE(logEntry.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo)); - // get this logentry with filter QVariantMap params; params.insert("deviceIds", QVariantList() << device->id()); diff --git a/tests/auto/rules/testrules.cpp b/tests/auto/rules/testrules.cpp index a7799895..fde81098 100644 --- a/tests/auto/rules/testrules.cpp +++ b/tests/auto/rules/testrules.cpp @@ -82,6 +82,8 @@ private slots: void testEventBasedAction(); + void removePolicy(); + void testRuleActionParams_data(); void testRuleActionParams(); }; @@ -1476,7 +1478,6 @@ void TestRules::enableDisableRule() response = injectAndWait("Rules.DisableRule", disableParams); verifyRuleError(response); - // trigger event in mock device spy.clear(); request = QNetworkRequest(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockDevice1Port).arg(mockEvent1Id.toString()))); @@ -1560,6 +1561,44 @@ void TestRules::testEventBasedAction() verifyRuleExecuted(mockActionIdWithParams); // TODO: check if this action was realy executed with the int state value 42 +} + +void TestRules::removePolicy() +{ + // ADD parent device + QVariantMap params; + params.insert("deviceClassId", mockParentDeviceClassId); + params.insert("name", "Parent device"); + + QVariant response = injectAndWait("Devices.AddConfiguredDevice", params); + verifyDeviceError(response); + + DeviceId parentDeviceId = DeviceId(response.toMap().value("params").toMap().value("deviceId").toString()); + QVERIFY(!parentDeviceId.isNull()); + + // find child device + response = injectAndWait("Devices.GetConfiguredDevices"); + + QVariantList devices = response.toMap().value("params").toMap().value("devices").toList(); + + DeviceId childDeviceId; + foreach (const QVariant deviceVariant, devices) { + QVariantMap deviceMap = deviceVariant.toMap(); + + if (deviceMap.value("deviceClassId").toString() == mockChildDeviceClassId.toString()) { + if (deviceMap.value("parentId") == parentDeviceId.toString()) { + //qDebug() << QJsonDocument::fromVariant(deviceVariant).toJson(); + childDeviceId = DeviceId(deviceMap.value("id").toString()); + } + } + } + QVERIFY2(!childDeviceId.isNull(), "Could not find child device"); + + // Add rule with child device + + + + } void TestRules::testRuleActionParams_data()