Exemple #1
0
 def _process_telemetry(self, telemetry_name: str, schema, telemetry):
     expected_type = extract_schema_type(schema)
     is_payload_valid = validate(schema, telemetry)
     if expected_type and not is_payload_valid:
         details = strings.invalid_primitive_schema_mismatch_template(
             telemetry_name, expected_type, telemetry)
         self._add_central_issue(severity=Severity.error, details=details)
 def test_extract_schema_type_component(self):
     expected_mapping = {
         "component1Prop": "boolean",
         "testComponent": "boolean",
         "component1PropReadonly": "boolean",
         "component1Prop2": "boolean",
     }
     template = Template(
         load_json(FileNames.central_property_validation_template_file))
     for key, val in expected_mapping.items():
         schema = template.get_schema(key, is_component=True)
         schema_type = extract_schema_type(schema)
         assert schema_type == val
Exemple #3
0
 def test_extract_schema_type_component_identifier(self):
     expected_mapping = {
         "component2prop": "boolean",
         "component2Prop2": "boolean",
         "testComponent": "boolean",
         "component2PropReadonly": "boolean",
     }
     template = central_models.TemplateV1(
         load_json(FileNames.central_property_validation_template_file)
     )
     for key, val in expected_mapping.items():
         schema = template.get_schema(
             key, is_component=True, identifier="RS40OccupancySensorV36fy"
         )
         schema_type = extract_schema_type(schema)
         assert schema_type == val
 def test_extract_schema_type(self):
     expected_mapping = {
         "Bool": "boolean",
         "Date": "date",
         "DateTime": "dateTime",
         "Double": "double",
         "Duration": "duration",
         "IntEnum": "Enum",
         "StringEnum": "Enum",
         "Float": "float",
         "Geopoint": "geopoint",
         "Long": "long",
         "Object": "Object",
         "String": "string",
         "Time": "time",
         "Vector": "vector",
     }
     template = Template(load_json(FileNames.central_device_template_file))
     for key, val in expected_mapping.items():
         schema = template.get_schema(key)
         schema_type = extract_schema_type(schema)
         assert schema_type == val