class CustomObjectTestCases(GWClientTestCase): def setUp(self): super(CustomObjectTestCases, self).setUp() self.topology.gatewayClients[0].DefineTestObjects() self.topology.gatewayClients[0].CreateInstancesOfTestObjects() @parameterized.expand([ # Create object instance test cases ["SetGetMandatoryStringResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/202", AwaResourceType.String, "test"), SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0/202", AwaResourceType.String, "Imagination Technologies"), GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/202", AwaResourceType.String, "Imagination Technologies"), )], ["SetGetMandatoryStringArrayResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/209", AwaResourceType.StringArray, {1: "Sample1", 2: "Sample2", 3: "Sample3"}), SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0/209", AwaResourceType.StringArray, {0: "Sample0", 20: "Sample20"}), GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/209", AwaResourceType.StringArray, {0: "Sample0", 20: "Sample20"}), )], ["SetGetMandatoryIntegerArrayResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/210", AwaResourceType.IntegerArray, {0: 5, 1: 10, 2: 15}), SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0/210", AwaResourceType.IntegerArray, {3: 5, 4: 10, 5: 15}), GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/210", AwaResourceType.IntegerArray, {3: 5, 4: 10, 5: 15}), )], ["UpdateMandatoryIntegerArrayResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/210", AwaResourceType.IntegerArray, {3: 5, 4: 10, 5: 15}), SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0/210", AwaResourceType.IntegerArray, {6: 20}, False, False, True), GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/210", AwaResourceType.IntegerArray, {3: 5, 4: 10, 5: 15, 6: 20}), )], ["SetGetOptionalStringResource", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0/102", None, None, False, True), # create resource GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/102", AwaResourceType.String, "test"), SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0/102", AwaResourceType.String, "Imagination Technologies"), GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/102", AwaResourceType.String, "Imagination Technologies"), )], # Set negative test cases ["SetIntegerValueOnUndefinedObject", (SetAssertion(set_operation_assertions.CheckForNotDefinedWhenAddingValue, "/9999/0/0", AwaResourceType.Integer, 1234), )], ["SetIntegerValueOnUndefinedObjectInstance", (SetAssertion(set_operation_assertions.CheckForNotDefinedWhenAddingValue, "/1000/9999/0", AwaResourceType.Integer, 1234), )], ["SetIntegerValueOnUndefinedResource", (SetAssertion(set_operation_assertions.CheckForNotDefinedWhenAddingValue, "/1000/0/9999", AwaResourceType.Integer, 1234), )], ["SetIntegerValueOnInvalidPath", (SetAssertion(set_operation_assertions.CheckForPathInvalid, "/@%@!#$/0/9999", AwaResourceType.Integer, 1234), )], # Get negative test cases ["GetIntegerValueOnUndefinedObject", (GetAssertion(get_operation_assertions.CheckForPathNotFound, "/9999/0/0", AwaResourceType.Integer, 1234), )], ["GetIntegerValueOnUndefinedObjectInstance", (GetAssertion(get_operation_assertions.CheckForPathNotFound, "/1000/9999/0", AwaResourceType.Integer, 1234), )], ["GetIntegerValueOnUndefinedResource", (GetAssertion(get_operation_assertions.CheckForPathNotFound, "/1000/0/9999", AwaResourceType.Integer, 1234), )], ["GetIntegerValueOnInvalidPath", (GetAssertion(get_operation_assertions.CheckForPathInvalid, "/@%@!#$/0/9999", AwaResourceType.Integer, 1234), )], # subscribe test cases ["SubscribeToChangeStringResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/202", AwaResourceType.String, "test"), SubscribeAssertion(subscribe_operation_assertions.CheckForSuccess, "/1000/0/202", AwaResourceType.String, "test2", True), )], ["SubscribeToChangeStringArrayResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/209", AwaResourceType.StringArray, {1: "Sample1", 2: "Sample2", 3: "Sample3"}), SubscribeAssertion(subscribe_operation_assertions.CheckForSuccess, "/1000/0/209", AwaResourceType.StringArray, {0: "Sample0", 5: "Sample5"}, True, True), )], ], testcase_func_name=noseParameterisedTestNameGenerator) def test(self, name, assertions): test_assertions.callAssertions(self, assertions)
class CustomObjectDeleteTestCases(GWClientTestCase): def setUp(self): super(CustomObjectDeleteTestCases, self).setUp() self.topology.gatewayClients[0].DefineTestObjects() self.topology.gatewayClients[0].CreateInstancesOfTestObjects() @parameterized.expand([ # Delete resource test cases ["DeleteMandatoryResource", (DeleteAssertion(client_delete_assertions.CheckForSuccess, "/1000/0/202"), )], ["DeleteOptionalResource", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0/102", AwaResourceType.String, None, False, True), DeleteAssertion(client_delete_assertions.CheckForSuccess, "/1000/0/102"), )], ["DeleteNonExistentResource", (DeleteAssertion(client_delete_assertions.CheckForPathNotFound, "/1000/0/102"), )], ["DeleteUndefinedResource", (DeleteAssertion(client_delete_assertions.CheckForPathNotFound, "/1000/0/999"), )], # Delete object instance success cases ["DeleteMandatoryObjectInstance", (DeleteAssertion(client_delete_assertions.CheckForSuccess, "/1001/0"), )], ["DeleteOptionalObjectInstance", (DeleteAssertion(client_delete_assertions.CheckForSuccess, "/1000/0"), )], ["DeleteNonExistentObjectInstance", (DeleteAssertion(client_delete_assertions.CheckForPathNotFound, "/1000/999"), )], ["DeleteUndefinedObject", (DeleteAssertion(client_delete_assertions.CheckForPathNotFound, "/9999"), )], # TODO delete whole object cases ], testcase_func_name=noseParameterisedTestNameGenerator) def test(self, name, assertions): test_assertions.callAssertions(self, assertions)
def CheckForSuccess(testCase, assertion): session = testCase.topology.gatewayClients[0]._session subscription = testCase.topology.gatewayClients[ 0].CreateChangeSubscription(assertion.path) testCase.topology.gatewayClients[0].SubscribeToChange( session, subscription) if assertion.setWithDaemon: set_operation_assertions.CheckForSuccess( testCase, SetAssertion(None, assertion.path, assertion.resourceType, assertion.expectedValue, appendArray=assertion.appendArray)) testCase.topology.gatewayClients[0].WaitForNotification( session, assertion.path) notifyValue = testCase.topology.gatewayClients[0].GetNotifyResponse( assertion.path) testCase.assertEqual(notifyValue, assertion.expectedValue) testCase.topology.gatewayClients[0].CancelSubscribeToChange( session, subscription) testCase.topology.gatewayClients[0].FreeChangeSubscription(subscription)
class DeviceObjectGetSetResourceDeviceServerCheck(GWClientNUCTestCase): @parameterized.expand([ # Daemon GET/SET operations. Both should succeed even if the resource is read only because the client daemon has control over all its resources. # Read the initial value, then see that it has changed after the set operation. ["SetGetManufacturerResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/0", AwaResourceType.String, "Imagination Technologies"), SetAssertion(set_operation_assertions.CheckForSuccess, "/3/0/0", AwaResourceType.String, "Imagination Technologies 123"), GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/0", AwaResourceType.String, "Imagination Technologies 123"), GetAssertion(device_server_get_operation_assertions.CheckForSuccess, "/3/0/0", AwaResourceType.String, "Imagination Technologies 123"), )], ["SetGetModelNumberResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/1", AwaResourceType.String, "Awa Client"), SetAssertion(set_operation_assertions.CheckForSuccess, "/3/0/1", AwaResourceType.String, "Awa Client 213"), GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/1", AwaResourceType.String, "Awa Client 213"), GetAssertion(device_server_get_operation_assertions.CheckForSuccess, "/3/0/1", AwaResourceType.String, "Awa Client 213"), )], ["SetGetSerialNumberResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/2", AwaResourceType.String, "SN12345678"), SetAssertion(set_operation_assertions.CheckForSuccess, "/3/0/2", AwaResourceType.String, "SN135792468"), GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/2", AwaResourceType.String, "SN135792468"), GetAssertion(device_server_get_operation_assertions.CheckForSuccess, "/3/0/2", AwaResourceType.String, "SN135792468"), )], ["SetGetPowerSourceCurrentResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/8", AwaResourceType.IntegerArray, {0: 125, 1: 900}), SetAssertion(set_operation_assertions.CheckForSuccess, "/3/0/8", AwaResourceType.IntegerArray, {0: 123, 1: 456}), GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/8", AwaResourceType.IntegerArray, {0: 123, 1: 456}), GetAssertion(device_server_get_operation_assertions.CheckForSuccess, "/3/0/8", AwaResourceType.IntegerArray, {0: 123, 1: 456}), )], # TODO rest of device resources ^^ # Negative Get test cases ["GetManufacturerResourceWithWrongType", (GetAssertion(get_operation_assertions.CheckForTypeMismatch, "/3/0/0", AwaResourceType.Integer, None), )], ["GetUndefinedResource", (GetAssertion(get_operation_assertions.CheckForPathNotFound, "/3/0/100", AwaResourceType.String, None), )], # Negative Set test cases ["SetMultipleValuesOnSingleInstanceResource", (SetAssertion(set_operation_assertions.CheckForTypeMismatchWhenAddingValue, "/3/0/0", AwaResourceType.StringArray, {0: "Imagination Technologies", 1: "Imagination Technologies 2"}), )], ], testcase_func_name=noseParameterisedTestNameGenerator) def test(self, name, assertions): test_assertions.callAssertions(self, assertions)
class DeviceObjectCreate(GWClientTestCase): @parameterized.expand([ # Daemon create object instance ############################################################################ ["DaemonCreateDeviceObjectInstance", (DeleteAssertion(client_delete_assertions.CheckForSuccess, "/3/0"), SetAssertion(set_operation_assertions.CheckForSuccess, "/3/0", None, None, True), )], ["DaemonCreateExistingDeviceObjectInstance", (SetAssertion(set_operation_assertions.CheckForCannotCreate, "/3/0", None, None, True), )], # Daemon create resources ############################################################################ ["DaemonCreateFirmwareVersionResourceWithValue", (DeleteAssertion(client_delete_assertions.CheckForSuccess, "/3/0/3"), SetAssertion(set_operation_assertions.CheckForSuccess, "/3/0/3", AwaResourceType.String, "test", False, True), GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/3", AwaResourceType.String, "test"), )], ["DaemonCreateExistingFirmwareVersionResource", (SetAssertion(set_operation_assertions.CheckForCannotCreate, "/3/0/3", None, None, False, True), )], ], testcase_func_name=noseParameterisedTestNameGenerator) def test(self, name, assertions): test_assertions.callAssertions(self, assertions)
class DeviceObjectDelete(GWClientTestCase): @parameterized.expand([ # Daemon delete resource ["DeleteManufacturerResource", (GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/0", AwaResourceType.String, "Imagination Technologies"), DeleteAssertion(client_delete_assertions.CheckForSuccess, "/3/0/0"), GetAssertion(get_operation_assertions.CheckForPathNotFound, "/3/0/0", AwaResourceType.String, None), )], #FIXME https,//issues.ba.imgtec.org/browse/FLOWDM-673 ["DeleteRebootResource", (DeleteAssertion(client_delete_assertions.CheckForSuccess, "/3/0/4"), DeleteAssertion(client_delete_assertions.CheckForPathNotFound, "/3/0/4"), )], ["DeleteNonDefinedResource", (DeleteAssertion(client_delete_assertions.CheckForPathNotFound, "/3/0/888"), )], # Daemon delete object instance ["DeleteDeviceObjectInstance", (DeleteAssertion(client_delete_assertions.CheckForSuccess, "/3/0"), DeleteAssertion(client_delete_assertions.CheckForPathNotFound, "/3/0"), )], ["DeleteNonExistentObjectInstance", (DeleteAssertion(client_delete_assertions.CheckForPathNotFound, "/3/1"), )], ["DeleteAvailablePowerSourceResourceInstances", (GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/6", AwaResourceType.IntegerArray, {0: 15, 1: 25}), DeleteAssertion(client_delete_assertions.CheckForSuccess, "/3/0/6", 0, 2), GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/6", AwaResourceType.IntegerArray, {}), )], ["DeleteErrorCodeResourceResourceInstances", (GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/11", AwaResourceType.IntegerArray, {0: 0}), DeleteAssertion(client_delete_assertions.CheckForSuccess, "/3/0/11", 0, 1), GetAssertion(get_operation_assertions.CheckForSuccess, "/3/0/11", AwaResourceType.IntegerArray, {}), )], ["DeleteAndCreateMemoryFreeResource", (DeleteAssertion(client_delete_assertions.CheckForSuccess, "/3/0/10"), SetAssertion(set_operation_assertions.CheckForSuccess, "/3/0/10", None, None, False, True), )], ], testcase_func_name=noseParameterisedTestNameGenerator) def test(self, name, assertions): test_assertions.callAssertions(self, assertions)
class CustomObjectCreateTestCases(GWClientTestCase): def setUp(self): super(CustomObjectCreateTestCases, self).setUp() self.topology.gatewayClients[0].DefineTestObjects() @parameterized.expand([ # Create object instance test cases ["CreateSingleOptionalObjectInstance", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0", None, None, True), )], ["CreateSingleMandatoryObjectInstance", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1001/0", None, None, True), )], ["CreateMultipleObjectInstance", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1002/0", None, None, True), )], ["CreateExistingSingleObjectInstance", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0", None, None, True), SetAssertion(set_operation_assertions.CheckForCannotCreate, "/1000/0", None, None, True), )], ["CreateExistingMultipleObjectInstance", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1002/0", None, None, True), SetAssertion(set_operation_assertions.CheckForCannotCreate, "/1002/0", None, None, True), )], ["CreateMultipleOnSingleObjectInstance", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0", None, None, True), SetAssertion(set_operation_assertions.CheckForCannotCreate, "/1000/1", None, None, True), )], ["CreateMultipleOnMultipleObjectInstance", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1002/0", None, None, True), SetAssertion(set_operation_assertions.CheckForSuccess, "/1002/1", None, None, True), )], # Create resource test cases ["CreateStringArrayResource", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0", None, None, True), SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0/109", AwaResourceType.StringArray, None, False, True), GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/109", AwaResourceType.StringArray, {1: "Sample1", 2: "Sample2", 3: "Sample3"}), )], ["CreateExistingStringArrayResource", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0", None, None, True), SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0/109", AwaResourceType.StringArray, None, False, True), SetAssertion(set_operation_assertions.CheckForCannotCreate, "/1000/0/109", AwaResourceType.StringArray, None, False, True), )], ["CreateStringArrayResourceWithValue", (SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0", None, None, True), SetAssertion(set_operation_assertions.CheckForSuccess, "/1000/0/109", AwaResourceType.StringArray, {0: "Sample0", 2: "Sample2"}, False, True), GetAssertion(get_operation_assertions.CheckForSuccess, "/1000/0/109", AwaResourceType.StringArray, {0: "Sample0", 2: "Sample2"}), )], ], testcase_func_name=noseParameterisedTestNameGenerator) def test(self, name, assertions): test_assertions.callAssertions(self, assertions)