示例#1
0
 def test_BuilderToSimple_CustomTypes_GetCorrectStructure(self):
     for type_ in self.OBSERVABLE_CUSTOM_BUILDER_STRUCTURES:
         builder_dict = self.OBSERVABLE_CUSTOM_BUILDER_STRUCTURES[type_]
         simple = ObservableStructureConverter.builder_to_simple(
             builder_dict.get('objectType'), builder_dict)
         self.assertDictEqual(
             simple, self.OBSERVABLE_CUSTOM_SIMPLE_STRUCTURES[type_])
示例#2
0
 def __validate_observables(observables):
     validation_results = {}
     dummy_id = 1
     for observable in observables:
         id_ = observable.get('id')
         object_type = observable.get('objectType')
         if not id_:
             # No id, so we can safely assume this is something from the builder...
             observable_properties = ObservableStructureConverter.builder_to_simple(
                 object_type, observable)
             validation_info = ObservableValidator.validate(
                 **observable_properties)
             validation_results[
                 'Observable ' +
                 str(dummy_id)] = validation_info.validation_dict
         else:
             namespace_validation = NamespaceValidationInfo.validate(
                 r'obs', id_)
             if namespace_validation.is_local():
                 real_observable = EdgeObject.load(id_)
                 as_package, _ = real_observable.capsulize('temp')
                 validation_info = PackageValidationInfo.validate(
                     as_package)
                 validation_results.update(validation_info.validation_dict)
             else:
                 validation_results.update(
                     {id_: namespace_validation.validation_dict})
         dummy_id += 1
     return validation_results
示例#3
0
 def test_BuilderToSimple_AnyValidShorthandType_GetsCorrectFullType(self):
     with mock.patch.object(
             ObservableStructureConverter,
             '_ObservableStructureConverter__get_builder_package_conversion_handler',
             return_value=None):
         for type_ in self.OBSERVABLE_TYPES:
             simple = ObservableStructureConverter.builder_to_simple(
                 type_, {})
             self.assertEqual(simple.get('object_type'),
                              self.OBSERVABLE_TYPES[type_])
示例#4
0
 def test_BuilderToSimple_GenericTypes_GetCorrectStructure(self):
     builder_dict = self.GENERIC_OBSERVABLE_STRUCTURES['BUILDER']
     simple = ObservableStructureConverter.builder_to_simple(
         builder_dict.get('objectType'), builder_dict)
     self.assertDictEqual(simple,
                          self.GENERIC_OBSERVABLE_STRUCTURES['SIMPLE'])