예제 #1
0
 def test_glued_code(self):
     prop = PropertyMaker()
     PropertyMaker().migrateMethods(self.a)
     Mutator().rebind(prop.getPrivateMehtods, self.a)
     for methodProp, methodA in (zip(prop.getPrivateMehtods(),
                                     self.a.getPrivateMehtods())):
         self.assertEqual(inspect.getsource(methodProp),
                          inspect.getsource(methodA))
 def __init__(self, *args, **kwargs):
     PropertyMaker().buildProperty(self, 'persist_to', 'melta') \
         .buildProperty(self, 'remove_on_cascade', False) \
         .buildProperty(self, 'enable_transactions', True) \
         .buildProperty(self, 'syncronization_strategy', None)
     for k, v in kwargs.items():
         self._update_property_by_name(k, v)
예제 #3
0
 def __init__(self, melta_object):
     original_class = melta_object.instance_name if melta_object.get_data_type(
     ) == INSTANCE_TYPE else melta_object.get_data_type()
     PropertyMaker().buildProperty(self, 'created_at', datetime.datetime.now()) \
         .buildProperty(self, 'modified_at', datetime.datetime.now()) \
         .buildProperty(self, 'melta_object', melta_object) \
         .buildProperty(self, 'schema') \
         .buildProperty(self, 'object_status', CLEAN_MELTAOBJECT_STATUS) \
         .buildProperty(self, 'original_class', original_class) \
         .buildProperty(self, 'object_references', set())
 def __init__(self):
     super().__init__()
     PropertyMaker().buildProperty(self, 'another_attr', 130)
 def add_property(self, property_name, property_value=None):
     PropertyMaker().buildProperty(self, property_name, property_value)
예제 #6
0
 def tets_chained_boolean(self):
     PropertyMaker().buildProperty(self.a, 'somthg', False) \
         .buildProperty(self.a, 'prop', 34)
     self.assertEqual(self.a.prop, 34)
     self.assertEqual(self.a.somthg, False)
예제 #7
0
 def test_boolean_property(self):
     PropertyMaker().buildProperty(self.a, 'somthg', False)
     self.assertEqual(self.a.somthg, False)
     self.assertFalse(self.a.somthg)
예제 #8
0
 def test_build_properties_chained(self):
     PropertyMaker().buildProperty(self.a, 'data', 3) \
         .buildProperty(self.a, 'something', 'a')
     self.assertEqual(self.a.data, 3)
     self.assertEqual(self.a.something, 'a')
예제 #9
0
 def __init__(self, schema, created_at=datetime.datetime.now()):
     PropertyMaker().buildProperty(self, 'schema', schema)
     #objects_name_space is a dictionary with Melta object name key and a set of melta objects with that name identifier.
     self.objects_name_space = {}
     PropertyMaker().buildProperty(self, 'created_at', created_at) \
         .buildProperty(self, 'object_count', 0)
예제 #10
0
 def test_assign_instance(self):
     b = B()
     PropertyMaker().buildProperty(self.a, 'instanceB', b)
     self.assertEqual(b, self.a.instanceB)
예제 #11
0
 def test_build_properties(self):
     PropertyMaker().buildProperties(self.a, {'dato': "ddd", "saraza": 2})
     self.assertEqual(self.a.dato, "ddd")
     self.assertEqual(self.a.saraza, 2)
예제 #12
0
 def test_build_properties_string(self):
     PropertyMaker().buildProperty(self.a, 'dato', "ddd")
     self.assertEqual(self.a.dato, "ddd")
예제 #13
0
 def test_build_property(self):
     PropertyMaker().buildProperty(self.a, 'saraza', 2)
     self.assertEqual(self.a.saraza, 2)
예제 #14
0
 def __init__(self, atribute):
     PropertyMaker().buildProperty(self, 'attribute', atribute)
 def __init__(self):
     #This class inherits from PyObjectSyncronize but it wasn't called the superclass deliberately
     PropertyMaker().buildProperty(self, "an_attr", 50)
 def __init__(self):
     PropertyMaker().buildProperty(self, "un_atributo", 30) \
         .buildProperty(self, "otro_atributo", "algo")
예제 #17
0
from melta.dynamic.propertyMaker import PropertyMaker

property_maker = PropertyMaker()


class Person:
    pass


person1 = Person()

property_maker.buildProperty(person1, "edad", 20) \
    .buildProperty(person1, "altura", 180) \
    .buildProperty(person1, "sexo", "male")


class House:
    pass


house1 = House()
property_maker.buildProperty(house1, "antiguedad", 32) \
    .buildProperty(house1, "tipo_casa", "bungalow") \
    .buildProperty(house1, "mt2", 360)

house2 = House()
property_maker.buildProperty(house2, "building_age", 34) \
    .buildProperty(house2, "material", "brick") \
    .buildProperty(house2, "sq2mts", 453)