Commits

Brian Michelich committed dbb9768

added config required_only override

  • Participants
  • Parent commits 1e1a117

Comments (0)

Files changed (5)

appengine_config.py

 #     return app
 
 
+builder_REQUIRED_ONLY = False
 # builder_RANDOM_STRING_LENGTH = 4
 def builder_entity_builder():
-    from tests.entity_builder import ConfOverride_url
-    overrides = {'ConfOverride_url':ConfOverride_url}
+    try:
+        from tests.entity_builder import EntityBuilderModel_first_name
+        overrides = {'EntityBuilderModel_first_name':EntityBuilderModel_first_name}
+    except:
+        overrides = {}
     return overrides
 

lib/ae_test_data/builder.py

     STRING_LENGTH = 6
     
     DEFAULT_CONSTRUCTOR = None
+    REQUIRED_ONLY = True
     
     BUILDABLE_PROPERTIES = [
         'BlobProperty',
 
 def build(cls, *args, **kwargs):
     cls_properties = cls.properties()
-    required_only = kwargs.get('required_only', True)
+    required_only_kwarg = kwargs.get('required_only')
+
+    if required_only_kwarg is not None:
+        required_only = bool(required_only_kwarg)
+    else:
+        required_only = config.REQUIRED_ONLY
+    
+
     constructor = kwargs.get('constructor')
     if constructor: del kwargs['constructor']
     

tests/entity_builder.py

 
 
-def ConfOverride_url(_property):
-    return 'http://www.domain.com'
+def EntityBuilderModel_first_name(_property):
+    return 'Mark'
 
 
         self.assertRegexpMatches(derived_model.last_name, 'last_name_+')
         self.assertRegexpMatches(derived_model.full_name, 'first_name_.+last_name_.+')
 
+    def test_reference_property(self):
+        pass
+    
+    def test_self_reference_property(self):
+        pass
+
 
 class EntityBuilderTests(DataStoreTestCase, TestCase):
-    pass
+    def test_entity_builer(self):
+        class EntityBuilderModel(db.Model):
+            first_name = db.StringProperty(required=True)
+        
+        entity_builder_model = build(EntityBuilderModel)
+        self.assertEqual('Mark', entity_builder_model.first_name)
 
 
 class ConstructorBuildParamTests(DataStoreTestCase, TestCase):
-- add exclude types - ie, aetycoon
-- dates should be now()?
 - reference_property returns None
 - config pattern if key exists for Model.attr, call it
 -- Offer.url -> return url
 
-- DateProperty - do nothing if has attr auto_now_add
-
 - handle ReferenceProperty, SelfReferenceProperty
-- use default attr value if available - started, needs testing
--- Look in to StringListProp defaulting to [] when default=[] doesn't exist
 - reraise exception for unsupported attribute
 - remove/handle *args, don't want positional params