Commit eb8ca7f4 authored by Thomas Braun's avatar Thomas Braun
Browse files

test: Add DbGetDeviceAliasWorks

parent 5ddbb038
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -712,6 +712,57 @@ BOOST_FIXTURE_TEST_CASE(DbGetAttributeAliasWorks, AddAndExportDeviceFixture)
    }
}

BOOST_FIXTURE_TEST_CASE(DbGetDeviceAliasWorks, AddAndExportDeviceFixture)
{
    const std::string device_alias{"devAlias"};

    // no match
    {
        auto dd = MakeDeviceDataString(device_name);
        BOOST_CHECK_THROW(dp->command_inout("DbGetDeviceAlias", dd), Tango::DevFailed);
    }

    // put an alias first
    {
        auto dd = MakeDeviceDataStringArray({device_name, device_alias});
        BOOST_CHECK_NO_THROW(dp->command_inout("DbPutDeviceAlias", dd));
    }

    // get alias match
    {
        auto dd = MakeDeviceDataString(device_name);

        Tango::DeviceData reply;
        BOOST_CHECK_NO_THROW(reply = dp->command_inout("DbGetDeviceAlias", dd));
        std::string str;
        BOOST_CHECK(reply >> str);
        BOOST_CHECK_EQUAL(str, device_alias);
    }

    // list aliases with wildcard
    {
        auto dd = MakeDeviceDataString("dev*");

        Tango::DeviceData reply;
        BOOST_CHECK_NO_THROW(reply = dp->command_inout("DbGetDeviceAliasList", dd));

        auto vec = ExtractStringVector(reply);
        std::vector<std::string> ref = {device_alias};
        BOOST_CHECK_EQUAL_COLLECTIONS(std::begin(vec), std::end(vec), std::begin(ref), std::end(ref));
    }

    // list aliases no match
    {
        auto dd = MakeDeviceDataString("I_DONT_EXIST");

        Tango::DeviceData reply;
        BOOST_CHECK_NO_THROW(reply = dp->command_inout("DbGetDeviceAliasList", dd));

        auto vec = ExtractStringVector(reply);
        BOOST_CHECK(vec.empty());
    }
}

// covers class attribute/device attribute/class pipe/device pipe properties
BOOST_DATA_TEST_CASE_F(AddAndExportDeviceFixture,
                       ThreeParameterAttributeHistoryWorks,