def test_comply_refers_to(self):
        """
        Check if the message object is referenced correctly
        """
        container = TypeRulesContainer()
        proto_path = ProtoMessagePath(
            ["GroundTruth", "host_vehicle_id", "refers_to"])
        container.add_type_from_path(proto_path)

        rule = Rule(
            verb="refers_to",
            params="MovingObject",
            extra_params=dict(),
            path=proto_path,
            field_name="host_vehicle_id",
        )
        rule.root = container
        self.FRC.refers_to(self.linked_hvid1, rule)
        self.FRC.refers_to(self.linked_hvid2, rule)
        self.FRC.refers_to(self.linked_hvid1, rule)

        references_list = self.FRC.id_manager._references

        print(references_list)

        # Check the instance type of the reference
        self.assertIsInstance(references_list[0][0], GroundTruth)

        # Check the id assignment of the reference to the object
        self.assertEqual(references_list[0][0].host_vehicle_id.value, 0)
        self.assertEqual(references_list[0][1], 0)
        self.assertEqual(references_list[0][2], "MovingObject")
    def test_not_comply_last_element(self):
        field_list = [self.lb1, self.lb2]
        container = TypeRulesContainer()
        proto_path = ProtoMessagePath(['LaneBoundary', 'BoundaryPoint'])
        container.add_type_from_path(proto_path)
        container.add_type_from_path(ProtoMessagePath(['Vector3d']))

        rule = Rule(verb="last_element",
                    params={'width': [{'is_equal': 0.11}],
                            'height': [{'is_equal': 0.13}]},
                    path=proto_path,
                    extra_params=dict(),
                    field_name='boundary_line')
        rule.root = container
        compliance = self.FRC.last_element(field_list, rule)
        self.assertFalse(compliance)
    def test_not_comply_last_element(self):
        field_list = [self.lb1, self.lb2]
        container = TypeRulesContainer()
        proto_path = ProtoMessagePath(["LaneBoundary", "BoundaryPoint"])
        container.add_type_from_path(proto_path)
        container.add_type_from_path(ProtoMessagePath(["Vector3d"]))

        rule = Rule(
            verb="last_element",
            params={
                "width": [{"is_equal_to": 0.11}],
                "height": [{"is_equal_to": 0.13}],
            },
            path=proto_path,
            extra_params=dict(),
            field_name="boundary_line",
        )
        rule.root = container
        compliance = self.FRC.last_element(field_list, rule)
        self.assertFalse(compliance)
    def test_comply_is_globally_unique(self):
        """
        Test if the ID Manager has unique indices
        """
        container = TypeRulesContainer()
        proto_path = ProtoMessagePath(
            ["SensorView", "sensor_id", "is_globally_unique"])
        container.add_type_from_path(proto_path)

        rule = Rule(
            verb="is_globally_unique",
            field_name="sensor_id",
            extra_params=dict(),
            path=proto_path,
        )
        rule.root = container
        self.FRC.is_globally_unique(self.linked_sid, rule)
        self.FRC.is_globally_unique(self.linked_sid2, rule)
        self.FRC.is_globally_unique(self.linked_sid2, rule)
        index_dict = self.FRC.id_manager._index
        self.assertEqual(2, len(index_dict))