예제 #1
0
파일: test3.py 프로젝트: arbal/scratchbox
def test_insert1(env):
    users = []

    user1 = User()
    user1.oid = 1
    user1.name = 'Homer Simpson'
    user1.authid = 'homer'
    user1.email = '*****@*****.**'
    user1.birthday = datetime.date(1950, 12, 24)
    user1.is_friendly = True
    user1.tags = ['relaxed', 'beerfan']
    users.append(user1)

    user2 = User()
    user2.oid = 2
    user2.name = 'Crocodile Dundee'
    user2.authid = 'crocoboss'
    user2.email = '*****@*****.**'
    user2.birthday = datetime.date(1960, 2, 4)
    user2.is_friendly = False
    user2.tags = ['red', 'yellow']
    user2.referred_by = user1.oid
    users.append(user2)

    user3 = User()
    user3.oid = 3
    user3.name = 'Foobar Space'
    user3.authid = 'foobar'
    user3.email = '*****@*****.**'
    user3.birthday = datetime.date(1970, 5, 7)
    user3.is_friendly = True
    user3.tags = ['relaxed', 'beerfan']
    user3.referred_by = user1.oid
    users.append(user3)

    with Transaction(env, write=True) as txn:
        for user in users:
            _user = txn.users[user.oid]
            if not _user:
                txn.users[user.oid] = user
                #txn.users_by_authid[user.authid] = user.oid
                print('user stored', user)
            else:
                print('user loaded', _user)
예제 #2
0
def test_insert1(env):
    users = []

    user1 = User()
    user1.oid = 1
    user1.name = 'Homer Simpson'
    user1.authid = 'homer'
    user1.email = '*****@*****.**'
    user1.birthday = datetime.date(1950, 12, 24)
    user1.is_friendly = True
    user1.tags = ['relaxed', 'beerfan']
    users.append(user1)

    user2 = User()
    user2.oid = 2
    user2.name = 'Crocodile Dundee'
    user2.authid = 'crocoboss'
    user2.email = '*****@*****.**'
    user2.birthday = datetime.date(1960, 2, 4)
    user2.is_friendly = False
    user2.tags = ['red', 'yellow']
    user2.referred_by = user1.oid
    users.append(user2)

    user3 = User()
    user3.oid = 3
    user3.name = 'Foobar Space'
    user3.authid = 'foobar'
    user3.email = '*****@*****.**'
    user3.birthday = datetime.date(1970, 5, 7)
    user3.is_friendly = True
    user3.tags = ['relaxed', 'beerfan']
    user3.referred_by = user1.oid
    users.append(user3)

    with Transaction(env, write=True) as txn:
        for user in users:
            _user = txn.users[user.oid]
            if not _user:
                txn.users[user.oid] = user
                #txn.users_by_authid[user.authid] = user.oid
                print('user stored', user)
            else:
                print('user loaded', _user)
예제 #3
0
파일: test3.py 프로젝트: arbal/scratchbox
def test_insert3(env):
    oid = 4

    with Transaction(env, write=True) as txn:
        user = txn.users[oid]
        if not user:
            user = User()
            user.oid = oid
            user.name = 'Foobar Space'
            user.authid = 'foobar'
            user.email = '*****@*****.**'
            user.birthday = datetime.date(1970, 5, 7)
            user.is_friendly = True
            user.tags = ['relaxed', 'beerfan']
            user.referred_by = 1

            txn.users[oid] = user
            print('user stored', user)
        else:
            print('user loaded', user)
예제 #4
0
def test_insert3(env):
    oid = 4

    with Transaction(env, write=True) as txn:
        user = txn.users[oid]
        if not user:
            user = User()
            user.oid = oid
            user.name = 'Foobar Space'
            user.authid = 'foobar'
            user.email = '*****@*****.**'
            user.birthday = datetime.date(1970, 5, 7)
            user.is_friendly = True
            user.tags = ['relaxed', 'beerfan']
            user.referred_by = 1

            txn.users[oid] = user
            print('user stored', user)
        else:
            print('user loaded', user)