diff --git a/tests/integration.py b/tests/integration.py index 3964c31ec65486079fd56dca03cd38d9bde2e4e0..5795f54a7733d0bc798a6518089d088630b51513 100755 --- a/tests/integration.py +++ b/tests/integration.py @@ -212,40 +212,26 @@ class TestWithMockBackend(unittest.TestCase): return None - def test_vehicle_zones(self): - """Test that the mock backend’s only vehicle’s zones are listed.""" - mock_vehicle = self.__get_vehicle('mock') - - zones = mock_vehicle.get_zones() - self.assertEqual(len(zones), 1) - root_zone = zones[0] - - self.assertEqual(root_zone.get_path(), '/') - self.assertEqual(root_zone.get_parent_path(), '') - self.assertEqual(root_zone.get_tags(), []) - def test_vehicle_all_metadata(self): """Test getting all metadata from a vehicle.""" mock_vehicle = self.__get_vehicle('mock') - root_zone = Rhosydd.StaticZone.new('/') - mock_vehicle.get_all_metadata_async( - zone=root_zone, + mock_vehicle.get_metadata_async( + node_path='', callback=self._block_on_result_cb, user_data=self) (metadata, current_time) = \ - mock_vehicle.get_all_metadata_finish(self._block_on_result()) + mock_vehicle.get_metadata_finish(self._block_on_result()) - # The mock backend currently exports 70 attributes. - self.assertEqual(len(metadata), 70) + # The mock backend currently exports 42 attributes. + self.assertEqual(len(metadata), 42) # Pick a particular attribute to spot-check. for meta in metadata: - if meta.name != 'lightStatus.automaticHeadlights': + if meta.name != 'VehicleIdentification.bodyType': continue - self.assertEqual(meta.name, 'lightStatus.automaticHeadlights') - self.assertEqual(meta.zone_path, '/') + self.assertEqual(meta.name, 'VehicleIdentification.bodyType') self.assertEqual(meta.availability, Rhosydd.AttributeAvailability.AVAILABLE) self.assertEqual(meta.flags, Rhosydd.AttributeFlags.READABLE) @@ -253,31 +239,28 @@ class TestWithMockBackend(unittest.TestCase): def test_vehicle_all_attributes(self): """Test getting all attributes from a vehicle.""" mock_vehicle = self.__get_vehicle('mock') - root_zone = Rhosydd.StaticZone.new('/') - mock_vehicle.get_all_attributes_async( - zone=root_zone, + mock_vehicle.get_attributes_async( + node_path='', callback=self._block_on_result_cb, user_data=self) (attributes, current_time) = \ - mock_vehicle.get_all_attributes_finish(self._block_on_result()) + mock_vehicle.get_attributes_finish(self._block_on_result()) - # The mock backend currently exports 70 attributes. - self.assertEqual(len(attributes), 70) + # The mock backend currently exports 42 attributes. + self.assertEqual(len(attributes), 42) # Pick a particular attribute to spot-check. for attr in attributes: - if attr.metadata.name != 'lightStatus.automaticHeadlights': + if attr.metadata.name != 'IsMoving': continue self.assertEqual(attr.attribute.accuracy, 0.0) - self.assertEqual(attr.attribute.last_updated, 0) self.assertLessEqual(attr.attribute.last_updated, current_time) - self.assertEqual(attr.attribute.value, GLib.Variant('b', True)) + self.assertEqual(attr.attribute.value, GLib.Variant('b', False)) self.assertEqual(attr.metadata.name, - 'lightStatus.automaticHeadlights') - self.assertEqual(attr.metadata.zone_path, '/') + 'IsMoving') self.assertEqual(attr.metadata.availability, Rhosydd.AttributeAvailability.AVAILABLE) self.assertEqual(attr.metadata.flags, @@ -286,46 +269,41 @@ class TestWithMockBackend(unittest.TestCase): def test_vehicle_metadata(self): """Test getting metadata for a specific attribute from a vehicle.""" mock_vehicle = self.__get_vehicle('mock') - root_zone = Rhosydd.StaticZone.new('/') mock_vehicle.get_metadata_async( - zone=root_zone, - attribute_name='lightStatus.automaticHeadlights', + node_path='VehicleIdentification.bodyType', callback=self._block_on_result_cb, user_data=self) - (metadata, current_time) = \ + (metadatas, current_time) = \ mock_vehicle.get_metadata_finish(self._block_on_result()) - self.assertEqual(metadata.name, 'lightStatus.automaticHeadlights') - self.assertEqual(metadata.zone_path, '/') - self.assertEqual(metadata.availability, + for metadata in metadatas: + self.assertEqual(metadata.name, 'VehicleIdentification.bodyType') + self.assertEqual(metadata.availability, Rhosydd.AttributeAvailability.AVAILABLE) - self.assertEqual(metadata.flags, Rhosydd.AttributeFlags.READABLE) + self.assertEqual(metadata.flags, Rhosydd.AttributeFlags.READABLE) def test_vehicle_attribute(self): """Test getting a specific attribute from a vehicle.""" mock_vehicle = self.__get_vehicle('mock') - root_zone = Rhosydd.StaticZone.new('/') - mock_vehicle.get_attribute_async( - zone=root_zone, - attribute_name='lightStatus.automaticHeadlights', + mock_vehicle.get_attributes_async( + node_path='VehicleIdentification.bodyType', callback=self._block_on_result_cb, user_data=self) - (attribute, current_time) = \ - mock_vehicle.get_attribute_finish(self._block_on_result()) - - self.assertEqual(attribute.attribute.accuracy, 0.0) - self.assertEqual(attribute.attribute.last_updated, 0) - self.assertLessEqual(attribute.attribute.last_updated, current_time) - self.assertEqual(attribute.attribute.value, GLib.Variant('b', True)) - - self.assertEqual(attribute.metadata.name, - 'lightStatus.automaticHeadlights') - self.assertEqual(attribute.metadata.zone_path, '/') - self.assertEqual(attribute.metadata.availability, + (attributes, current_time) = \ + mock_vehicle.get_attributes_finish(self._block_on_result()) + + for attribute in attributes: + self.assertEqual(attribute.attribute.accuracy, 0.0) + self.assertLessEqual(attribute.attribute.last_updated, current_time) + self.assertEqual(attribute.attribute.value, GLib.Variant('s', 'default')) + + self.assertEqual(attribute.metadata.name, + 'VehicleIdentification.bodyType') + self.assertEqual(attribute.metadata.availability, Rhosydd.AttributeAvailability.AVAILABLE) - self.assertEqual(attribute.metadata.flags, + self.assertEqual(attribute.metadata.flags, Rhosydd.AttributeFlags.READABLE) def test_vehicle_attribute_repeatedly(self): @@ -335,18 +313,17 @@ class TestWithMockBackend(unittest.TestCase): the cache because we haven’t added a subscription (see T2042). """ speedo_vehicle = self.__get_vehicle('speedo') - root_zone = Rhosydd.StaticZone.new('/front,left/') - speedo_vehicle.get_attribute_async( - zone=root_zone, - attribute_name='wheelSpeed.value', + speedo_vehicle.get_attributes_async( + node_path='Signal.Acceleration.Y', callback=self._block_on_result_cb, user_data=self) - (attribute, current_time) = \ - speedo_vehicle.get_attribute_finish(self._block_on_result()) - - initial_value = attribute.attribute.value - subsequent_value = initial_value + (attributes, current_time) = \ + speedo_vehicle.get_attributes_finish(self._block_on_result()) + + for attribute in attributes: + initial_value = attribute.attribute.value + subsequent_value = initial_value start_time = GLib.get_monotonic_time() @@ -355,15 +332,15 @@ class TestWithMockBackend(unittest.TestCase): start_time + self.timeout_seconds * GLib.USEC_PER_SEC): time.sleep(0.5) # avoid a busy loop - speedo_vehicle.get_attribute_async( - zone=root_zone, - attribute_name='wheelSpeed.value', + speedo_vehicle.get_attributes_async( + node_path='Signal.Speed', callback=self._block_on_result_cb, user_data=self) - (attribute, current_time) = \ - speedo_vehicle.get_attribute_finish(self._block_on_result()) + (attributes, current_time) = \ + speedo_vehicle.get_attributes_finish(self._block_on_result()) - subsequent_value = attribute.attribute.value + for attribute in attributes: + subsequent_value = attribute.attribute.value def test_exported_objects(self): """Test the SDK API only exports the objects we expect.