Exemplo n.º 1
0
    def test_all_model_module_names_unique(self):
        names_of_ndb_model_subclasses = [
            clazz.__name__ for clazz in test_utils.get_storage_model_classes()
        ]

        self.assertEqual(len(set(names_of_ndb_model_subclasses)),
                         len(names_of_ndb_model_subclasses))
Exemplo n.º 2
0
 def test_all_fields_have_export_policy(self):
     """Ensure every field in every model has an export policy defined."""
     all_models = [
         clazz
         for clazz in test_utils.get_storage_model_classes()
         if (not clazz.__name__ in
             test_utils.BASE_MODEL_CLASSES_WITHOUT_DATA_POLICIES)
     ]
     for model in all_models:
         export_policy = model.get_export_policy()
         self.assertEqual(
             sorted([
                 python_utils.UNICODE(prop) for prop
                 in model._properties]), # pylint: disable=protected-access
             sorted(export_policy.keys())
         )
         self.assertTrue(
             set(export_policy.values()).issubset(
                 {
                     base_models.EXPORT_POLICY.EXPORTED,
                     (
                         base_models
                         .EXPORT_POLICY.EXPORTED_AS_KEY_FOR_TAKEOUT_DICT),
                     base_models.EXPORT_POLICY.NOT_APPLICABLE
                 })
         )
Exemplo n.º 3
0
    def _get_base_or_versioned_model_child_classes(self):
        """Get child model classes that inherit directly from BaseModel or
        VersionedModel, these are classes that are used directly for saving data
        and not just inherited from.
        """

        for clazz in test_utils.get_storage_model_classes():
            if (clazz.__name__
                    in test_utils.BASE_MODEL_CLASSES_WITHOUT_DATA_POLICIES):
                continue
            yield clazz
Exemplo n.º 4
0
 def test_get_models_which_should_be_exported(self):
     """Ensure that the set of models to export is the set of models with
     export policy CONTAINS_USER_DATA, and that all other models have
     export policy NOT_APPLICABLE.
     """
     all_models = [
         clazz for clazz in test_utils.get_storage_model_classes()
         if (not clazz.__name__ in
             test_utils.BASE_MODEL_CLASSES_WITHOUT_DATA_POLICIES)
     ]
     models_with_export = (
         takeout_service.get_models_which_should_be_exported())
     for model in all_models:
         export_policy = model.get_export_policy()
         if model in models_with_export:
             self.assertIn(base_models.EXPORT_POLICY.EXPORTED,
                           export_policy.values())
         else:
             self.assertNotIn(base_models.EXPORT_POLICY.EXPORTED,
                              export_policy.values())