def test_object(): from ekklesia.data import init_object, repr_object, extract_object, objects_equal class Sample(object): c = 3 def __init__(self): self.a = 1 self.b = 2 def some(self): pass x, y = Sample(), Sample() assert objects_equal(x, y) assert objects_equal(x, y, ('a', 'c')) y.c = 4 assert not objects_equal(x, y) assert not objects_equal(x, y, ('a', 'c')) assert objects_equal(x, y, ('a', 'b')) assert repr_object(x, ('a', 'b', 'c')) == 'Sample(a=1,b=2,c=3)' init_object(x, a=11, c=33) assert x.a == 11 and x.c == 33 assert repr_object(x, ('a', 'b', 'c')) == 'Sample(a=11,b=2,c=33)' assert extract_object(x, ('a', 'b')) == {'a': 11, 'b': 2} assert extract_object(x, ('a', 'b'), {'a': 1, 'c': 3}) == {'a': 1, 'b': 2}
def __repr__(member): replace = {} if 'location' in self.member_import: replace['location'] = self.get_location(member) if not self.department_table and 'department' in self.member_columns: replace['department'] = self.get_department(member) return repr_object(member, self.member_columns, replace)
def __repr__(member): replace={} if 'location' in self.member_import: replace['location'] = self.get_location(member) if not self.department_table and 'departments' in self.member_columns: replace['departments'] = self.get_departments(member) return repr_object(member,self.member_columns,replace)
def test_object(): from ekklesia.data import init_object, repr_object, extract_object, objects_equal class Sample(object): c = 3 def __init__(self): self.a = 1 self.b = 2 def some(self): pass x,y = Sample(),Sample() assert objects_equal(x,y) assert objects_equal(x,y,('a','c')) y.c = 4 assert not objects_equal(x,y) assert not objects_equal(x,y,('a','c')) assert objects_equal(x,y,('a','b')) assert repr_object(x,('a','b','c'))=='Sample(a=1,b=2,c=3)' init_object(x,a=11,c=33) assert x.a==11 and x.c==33 assert repr_object(x,('a','b','c'))=='Sample(a=11,b=2,c=33)' assert extract_object(x,('a','b'))=={'a':11,'b':2} assert extract_object(x,('a','b'),{'a':1,'c':3})=={'a':1,'b':2}
def __repr__(inv): return repr_object(inv,self.invite_columns)
def __repr__(obj): return repr_object(obj, self.department_columns + ['parent'])
def __repr__(obj): return repr_object(obj,list(self.department_columns)+['parent'])