Esempio n. 1
0
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}
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
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}
Esempio n. 5
0
 def __repr__(inv):
     return repr_object(inv,self.invite_columns)
Esempio n. 6
0
 def __repr__(obj):
     return repr_object(obj, self.department_columns + ['parent'])
Esempio n. 7
0
 def __repr__(obj):
     return repr_object(obj,list(self.department_columns)+['parent'])