tests: Use separate connection for sysrepo queries

As Jan pointed out, the tests should use separate sysrepo connection and
session than the code being tested, because it matches the reality.

This commit adds a helper macro that initializes sysrepo "client"
connection and session and fixes the already present sysrepo tests.

Change-Id: I27432722cc25127ba37b5277e3f340278bdda5ce
diff --git a/tests/hardware_ietf-hardware.cpp b/tests/hardware_ietf-hardware.cpp
index baa3ff5..0ff68a0 100644
--- a/tests/hardware_ietf-hardware.cpp
+++ b/tests/hardware_ietf-hardware.cpp
@@ -168,16 +168,15 @@
     SECTION("Test IETF Hardware from sysrepo's view")
     {
         TEST_SYSREPO_INIT_LOGS;
+        TEST_SYSREPO_INIT;
+        TEST_SYSREPO_INIT_CLIENT;
 
-        auto srConn = std::make_shared<sysrepo::Connection>();
-        auto srSess = std::make_shared<sysrepo::Session>(srConn);
-        auto srSubs = std::make_shared<sysrepo::Subscribe>(srSess);
         auto ietfHardwareSysrepo = std::make_shared<velia::ietf_hardware::sysrepo::Sysrepo>(srSubs, ietfHardware);
 
         SECTION("test last-change")
         {
             // at least check that there is some timestamp
-            REQUIRE(dataFromSysrepo(srSess, modulePrefix, SR_DS_OPERATIONAL).count("/last-change") > 0);
+            REQUIRE(dataFromSysrepo(client, modulePrefix, SR_DS_OPERATIONAL).count("/last-change") > 0);
         }
 
         SECTION("test components")
@@ -306,15 +305,15 @@
                 {"[name='ne:ctrl:emmc:lifetime']/sensor-data/units-display", "percent"},
             };
 
-            REQUIRE(dataFromSysrepo(srSess, modulePrefix + "/component", SR_DS_OPERATIONAL) == expected);
+            REQUIRE(dataFromSysrepo(client, modulePrefix + "/component", SR_DS_OPERATIONAL) == expected);
         }
 
         SECTION("test leafnode query")
         {
             const auto xpath = modulePrefix + "/component[name='ne:ctrl:emmc:lifetime']/class";
-            srSess->session_switch_ds(SR_DS_OPERATIONAL);
-            auto val = srSess->get_item(xpath.c_str());
-            srSess->session_switch_ds(SR_DS_RUNNING);
+            client->session_switch_ds(SR_DS_OPERATIONAL);
+            auto val = client->get_item(xpath.c_str());
+            client->session_switch_ds(SR_DS_RUNNING);
             REQUIRE(!!val);
             REQUIRE(val->data()->get_identityref() == "iana-hardware:sensor"s);
         }
diff --git a/tests/test_sysrepo_helpers.h b/tests/test_sysrepo_helpers.h
index 7c43336..9a8888e 100644
--- a/tests/test_sysrepo_helpers.h
+++ b/tests/test_sysrepo_helpers.h
@@ -43,3 +43,7 @@
     auto srConn = std::make_shared<sysrepo::Connection>();    \
     auto srSess = std::make_shared<sysrepo::Session>(srConn); \
     auto srSubs = std::make_shared<sysrepo::Subscribe>(srSess);
+
+#define TEST_SYSREPO_INIT_CLIENT                               \
+    auto clientConn = std::make_shared<sysrepo::Connection>(); \
+    auto client = std::make_shared<sysrepo::Session>(clientConn);